question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement spatial data types

See original GitHub issue

Implement support for spatial data types: GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION.

http://dev.mysql.com/doc/refman/5.7/en/spatial-datatypes.html

Required for #4.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
caleblloydcommented, Nov 2, 2016

I’ve read through MySqlGeometry a few times, and it seems very unfinished. The GEOMETRY type is supposed to be able to hold POINT, LINESTRING, or POLYGON, but from reading the source, it appears to me that MySqlGeometry only supports inserting POINT.

I can’t find anything about MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, or GEOMETRYCOLLECTION in Connector/NET.

.NET Core has no System.Data.Spatial namespace as of yet. Other versions of .NET have System.Data.Spatial.DbGeography, and it is probably tailored to work with SQL Server, which supports all of MySQL’s spatial types and more.

EF Core has an open issue (https://github.com/aspnet/EntityFramework/issues/1100) to add Spatial support, which will likely come with DB-agnostic spatial abstractions. The most useful approach to programmers would likely be a library outside of this one that implements these forthcoming DB-agnostic spatial abstractions for MySQL.

I ran a query through BigQuery’s Sample GitHub Content representing 10% of public content on GitHub, searching for MySqlGeometry. Only 2 repos showed up, Connector/NET and another which looks like it no longer even uses it.

Randomly sampled 10% of text file contents from [bigquery-public-data:github_repos.contents].

    SELECT
      sample_repo_name
    FROM
      [bigquery-public-data:github_repos.sample_contents]
    WHERE
      NOT binary
      AND sample_path LIKE '%.cs'
      AND content CONTAINS 'MySqlGeometry'

1   zlzforever/DotnetSpider     src/MySql.Data/Field.cs  
2   mysql/mysql-connector-net   Source/MySql.Data/Field.cs   
3   mysql/mysql-connector-net   Tests/MySql.Data.Tests/DataTypeTests.cs 

My recommendation is that we remove the 1.0 tag and put this on the backlog. Once .NET core has spatial abstractions, we can either accept a contribution for it, or document a third-party library that supports it well if one emerges.

We should still add support for the spatial types as binary objects, and let callers cast from binary on Read and to binary before Write.

0reactions
enkodellccommented, Jan 29, 2023

Here is what I used for EF 6, .Net Core 6:

            services.AddDbContext<AWSMariaSQLDbContext>(options => options.UseMySql(configuration.GetConnectionString("AWSMariaSQLDataConnection"), Microsoft.EntityFrameworkCore.ServerVersion.Parse("10.6.10-mariadb"), 
                options => options.UseNetTopologySuite())
            );

Then in my model builder:

        entity.Property(e => e.Location)
               .HasColumnName("Location")
               .HasColumnType("point");

My Model:

public Point Location { get; set; }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spatial Data Types Overview - SQL Server
There are two types of spatial data. The geometry data type supports planar, or Euclidean (flat-earth), data. The geometry data type both ...
Read more >
Spatial types in databases—ArcGIS Pro | Documentation
Spatial data types store the spatial attributes that allow you to visualize data on a map. Many databases automatically include spatial data types....
Read more >
What are spatial types?—ArcMap | Documentation
Spatial types are data types that store geometry data. All the spatial information is stored in the spatial column; there are no side...
Read more >
MySQL 8.0 Reference Manual :: 11.4 Spatial Data Types
Following the OGC specification, MySQL implements spatial extensions as a subset of the SQL with Geometry Types environment. This term refers to an...
Read more >
Geospatial Data Types and How You Can Use Them
9 geospatial data types: ways of representing places, people, and things on Earth · 1. Points of Interest · 2. Property · 3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found