geojson-net / geojson.net.contrib Goto Github PK
View Code? Open in Web Editor NEWRepository for all GeoJSON.Net *.Contrib projects
License: MIT License
Repository for all GeoJSON.Net *.Contrib projects
License: MIT License
Current version of library does not support NETStandard. Is it possible to make it compatible with NETStandard 2.0?
Hey I am not sure if I am doing something wrong or not. I am using GeoJson for states and am looking through my own data to add my data to it.
var data = await File.ReadAllTextAsync(Path.Combine(executingDirectory, StatesJson));
var collection = JsonConvert.DeserializeObject<FeatureCollection>(data);
foreach (var state in collection.Features)
{
var geo = state.ToSqlGeography(options.Value.Srid).MakeValid();
var records = myData.Where(i => SqlGeography.Point(i.Location.Y, i.Location.X, options.Value.Srid).MakeValid().STWithin(geo).Value);
if(records != null && records.Count() > 0)
{
state.Properties.Add("stateCount", records.GetMyData());
}
}
return collection;
The reason the Y goes in the latitude and X goes in the longitude is because of this. It works for 2 of the states (Washingotn and Utah which is where the data is expected) however it ends up filling up other states as well.
When I place a break point in the if statement it starts off with Washington with the expected results, and then Utah, but then it breaks on Arkansas.
The Washington geo
data for the boundry of the state comes out to be
| Name | Value | Type
-- | -- | -- | --
▶ | geo | {POLYGON ((-116.9980726794949 46.330169786151487, -117.02664974655227 47.72292715106596, -117.03142981653929 48.999309190458973, -120.00269628968556 49.000885321643864, -122.84 49.000000000000114, -122.49983068910967 48.180160223984387, -122.34002132224703 47.359951890647778, -122.58713802146673 47.095885321636388, -123.12 48.04, -124.56610107421875 48.379714965820426, -124.68721008300781 48.184432983398381, -124.39567 47.72017000000011, -124.079635 46.86475, -123.99867632678428 46.2830694871044, -123.77670365460955 46.282033189471633, -123.47137345441303 46.277253119484669, -123.22849422264113 46.186250922218562, -122.9379693202963 46.12909678810388, -122.75224422263926 45.93807485613678, -122.72578588930577 45.770333156917559, -122.65170772361546 45.63008331967734, -122.42045568910925 45.591997789078221, -122.17491512107449 45.595150051447945, -121.78809118715355 45.700983384781807, -121.56107662009549 45.732764390641307, -121.203889120094 45.689898790055224, -121.0467410894945 45.637498887711104, -120.83719315655094 45.672948920263423, -120.60963598695361 45.753900051448625, -120.15826818910023 45.740670884781935, -119.78730891989301 45.850767523779837, -119.59204952047821 45.932235419287906, -119.33699968145743 45.888336290055861, -118.97823605027111 45.992567653988658, -116.9150028145857 45.999983222022593, -116.90652787968992 46.177775987322832, -116.9980726794949 46.330169786151487))} | Microsoft.SqlServer.Types.SqlGeography
and here is the Arkansas
| Name | Value | Type
-- | -- | -- | --
▶ | geo | {POLYGON ((-89.662919481143419 36.023072821591967, -89.673513149763252 35.94000295668279, -89.775109015649065 35.799236355119717, -89.950266282902376 35.701877956681827, -89.988894416040552 35.536229152970236, -90.147101813502132 35.404996853165017, -90.13493201369738 35.113955186497193, -90.249240281927 35.020834255507239, -90.268283047226561 34.941459255506913, -90.446618415065814 34.866838487277448, -90.4503132799747 34.7218602564826, -90.584206916042945 34.454098822562258, -90.6995487129184 34.397461452770358, -90.876307949572748 34.261474921194306, -90.9821412829065 34.0551050888367, -91.20068091506883 33.706392523731139, -91.223444383493415 33.469326890592171, -91.1080767484018 33.2068364527656, -91.156239183297828 33.010000922165858, -92.001303880566837 33.043874823533173, -93.094027879594648 33.010517686488768, -94.059757046265162 33.012119655889819, -94.002086147827441 33.57991445569678, -94.233338182333569 33.583609320605646, -94.427538214886425 33.570380153938927, -94.479912279014258 33.635983384733464, -94.451361050172991 34.510710354138, -94.430173712933311 35.483312486303348, -94.628611212934118 36.540586452778939, -93.412587246457889 36.52629791925024, -92.30717668330243 36.523662421203355, -91.251478848011743 36.52314565688043, -90.112194383488969 36.461754055317684, -90.029098680363632 36.337937323546356, -90.141804979192216 36.230502020811556, -90.253994513697862 36.122549953753833, -90.315386115260608 36.023072821591967, -89.662919481143419 36.023072821591967))} | Microsoft.SqlServer.Types.SqlGeography
The records
variable inside the if statement for these states is filled with every result that is with in myData
a total of 21 records. Like I mentioned both Utah and Washington (which actually has data) turn out fine but all the others East of Utah are for some reason getting all records even if their latitude/longitude don't fall with in the polygons.
I have tried both SqlGeography.Point( ... ).STWithin(geo)
and geo.STContains(SqlGeography.Point( ... ))
both return the same results.
Lastly here is one of the points that is showing up in a state that shouldn't have any data {POINT (47.2219 -122.4479)}
yet some how the methods above are showing true even though the point shouldn't exist within that location.
Let me know if you need any more information, as I am really wanting to try to figure this out.
Hi guys!
I have a problem with conversion from SqlGeography to IGeometryObject (use method - MsSqlSpatialConvert.ToGeoJSONGeometry
).
At the entrance I submit Longitude, Latitude, and the output is a sequence contrary Latitude, Longitude.
May be bug at line 63,70 SqlGeographyGeoJSONSink.cs ?
Thanks.
Are you using an API that isn't available in v7.x? This inconsistent versioning is causing issues in a large project where I'm using this.
If it was an oversight, I'd be happy to submit a PR.
Thanks!
From PR #26
We'd been using GeoJSON.Net.Contrib.MsSqlSpatial in a few .NET Framework 4.5 projects, without issue.
Now we're trying to move to .NET 5, and we are having issues.
The most recent package we can find on .NuGet is 0.3.6, from July 2, 2020. And it has a dependency on .NETFramework v4.5.
Has anyone built an equivalent package that does support .NET 5?
Issue #49 from GeoJSON.Net
// GeoJSON.Net.Contrib.MsSqlSpatial referenced in project var geoJson = GeoJSONFactory.FromWKT(sring wkt, int srid);
Projects need to be packaged and published
Would it be possible to add support for Extended Well-Known Text to GeoJSON.Net.Contrib.MsSqlSpatial?
EWKT and EWKB – Extended Well-Known Text/Binary – A PostGIS-specific format that includes the spatial reference system identifier (SRID) and up to 4 ordinate values (XYZM).[15][16] For example: SRID=4326;POINT(-44.3 60.1) to locate a longitude/latitude coordinate using the WGS 84 reference coordinate system.
I was experimenting with WKB conversions but .ToWkb() gave me an error
{"Kan bestand of assembly GeoJSON.NetContrib.WkbConversions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null of een van de afhankelijkheden hiervan niet laden. Het systeem kan het opgegeven bestand niet vinden.":"GeoJSON.NetContrib.WkbConversions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}
It's in Dutch but I assume the message is clear. GeoJSON.NetContrib.WkbConversions could not be found
See changeset GeoJSON-Net/GeoJSON.Net@81080d3
GeographicPosition needs to be replaced with Position.
RFC 7946 The GeoJSON Format states:
A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections
But GeoJSON.Net.Contrib.MsSqlSpatial provides no way to make this property optional.
IGeometryObject geometryObject = sqlGeometry.ToGeoJSONGeometry();
var properties = new Dictionary<string, object>();
int id = 1;
Feature feature =
new Feature(
geometryObject,
properties,
id.ToString());
feature.BoundingBoxes = null;
return feature;
Expected behavior: [What you expect to happen]
Expect an overload with a flag determining whether or not BoundingBoxes
should be set or if null is provided to BoundingBoxes after creating the feature it should be respected.
Actual behavior: [What actually happens]
BoundingBoxes
is always populated.
Reproduces how often: [What percentage of the time does it reproduce?]
100%
You can get this information from the library being used that is causing the issue. Also, please include the OS and what version of the OS you're running.
Version Information: 0.3.1
Operating System: Windows 10
Any additional information, configuration or data that might be necessary to reproduce or resolve the issue.
I will be submitting a pull request with updated methods with an optional parameter and unit tests verifying the behavior as soon as I have the issue number to tag it with.
Hello,
First of all, congrats for the solution. Is quite complete and well done!
I am trying to deploy my solution using the Net.Contrib into a docker/container environment and I am having a hard time with the SqlServer.Types.
It keeps hitting the " Unable to load shared library 'SqlServerSpatial140.dll' or one of its dependencies" error.
I have tried put the dll in the app folder, in the usr/bin folder. everywhere.
Have you guys faced a scenario like this? Could you share me some wisdom?
Thanks in advance.
Is it possible to create a Nuget-package for GeoJSON.Net.Contrib.Wkb targeting .NET Framework 4.5 as well?
The current one requires .NET Framework 4.5.2 afaik.
Afaik, GeoJSON.Net and dependencies has packages targeting .NET Framework 4.5 as well.
thanks
#13
See Pros/Cons of having different librairies and packages.
(a dev who wants only MSSQL conversion and does not uses EF should not be imposed such payload)
SqlGeographyBuilder builder = new SqlGeographyBuilder();
builder.SetSrid(4326);
builder.BeginGeography(OpenGisGeographyType.MultiPolygon);
builder.EndGeography();
geoJSON = builder.ConstructedGeography.ToGeoJSONGeometry();
Code above results in the following exception:
An exception of type 'System.NotSupportedException' occurred in GeoJSON.Net.Contrib.MsSqlSpatial.dll but was not handled in user code
Additional information: Geometry type MultiPolygon is not supported yet.
whereas the code below will work fine:
SqlGeographyBuilder builder = new SqlGeographyBuilder();
builder.SetSrid(4326);
builder.BeginGeography(OpenGisGeographyType.MultiPolygon);
builder.BeginGeography(OpenGisGeographyType.Polygon);
builder.EndGeography();
builder.EndGeography();
geoJSON = builder.ConstructedGeography.ToGeoJSONGeometry();
The same also seems to apply to SqlGeometries.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.