Answered by:
How to work in Model item that have NetTopologySuite Geometry datatype in Asp.net core 3

Question
-
User2070555482 posted
Hi,
I'am working with the project the have spatial data. I used the NetTopologySuite to use Geometry / Point data type in my model. It's look like :
public Point GeoLocation { get; set; }
public string Street { get; set; }
public string PostalCode { get; set; }
public string City { get; set; }
public string Country { get; set; }
But when I excute my web api the json parameter on this is :
{ "geoLocation": { "coordinateSequence": { "ordinates": 0 }, "dimension": 0, "boundaryDimension": 0, "x": 0, "y": 0, "coordinate": { "x": 0, "y": 0, "z": 0, "m": 0 }, "ogcGeometryType": 1, "boundary": { "factory": { "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinateSequenceFactory": { "ordinates": 0 } }, "userData": {}, "srid": 0, "ogcGeometryType": 1, "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinate": { "x": 0, "y": 0, "z": 0, "m": 0 }, "dimension": 0, "boundaryDimension": 0, "envelopeInternal": { "centre": { "x": 0, "y": 0, "z": 0, "m": 0 } } }, "z": 0, "m": 0, "factory": { "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinateSequenceFactory": { "ordinates": 0 } }, "userData": {}, "srid": 0, "precisionModel": { "scale": 0, "precisionModelType": 0 }, "envelope": { "factory": { "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinateSequenceFactory": { "ordinates": 0 } }, "userData": {}, "srid": 0, "ogcGeometryType": 1, "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinate": { "x": 0, "y": 0, "z": 0, "m": 0 }, "dimension": 0, "boundaryDimension": 0, "envelopeInternal": { "centre": { "x": 0, "y": 0, "z": 0, "m": 0 } } }, "envelopeInternal": { "centre": { "x": 0, "y": 0, "z": 0, "m": 0 } } }
Is their a way to simplify it like
( <tt class="REPLACEABLE c2">x</tt> , <tt class="REPLACEABLE c2">y</tt> )
Cause in postgreSQL in look this, Thanks
Friday, February 14, 2020 7:33 AM
Answers
-
User-474980206 posted
to use the Geometry object directly you will need to learn it. also if converting to JSON be sue to use a library that works correctly. see:
https://github.com/NetTopologySuite/NetTopologySuite.IO.GeoJSON
then the client can deserialize with the above library and use the their api to modify the object.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, February 23, 2020 5:37 PM
All replies
-
User-854763662 posted
Hi TinVin727 ,
Is their a way to simplify it like
( <tt class="REPLACEABLE c2">x</tt> , <tt class="REPLACEABLE c2">y</tt> )
Did you mean to transfer the data in json in the above form?
What exactly do you want to achieve ? Please share more details so that we can better understand your problem ?
Best Regards,
Sherry
Monday, February 17, 2020 2:51 PM -
User2070555482 posted
Hi Sherry Chen,
I used Geometry datatype (NetTopplogySuite) for my model property (GeoLocation). This is where I can post or add a geolocation. But when i run it in swagger the json form is this
"geoLocation": { "coordinateSequence": { "ordinates": 0 }, "dimension": 0, "boundaryDimension": 0, "x": 0, "y": 0, "coordinate": { "x": 0, "y": 0, "z": 0, "m": 0 }, "ogcGeometryType": 1, "boundary": { "factory": { "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinateSequenceFactory": { "ordinates": 0 } }, "userData": {}, "srid": 0, "ogcGeometryType": 1, "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinate": { "x": 0, "y": 0, "z": 0, "m": 0 }, "dimension": 0, "boundaryDimension": 0, "envelopeInternal": { "centre": { "x": 0, "y": 0, "z": 0, "m": 0 } } }, "z": 0, "m": 0, "factory": { "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinateSequenceFactory": { "ordinates": 0 } }, "userData": {}, "srid": 0, "precisionModel": { "scale": 0, "precisionModelType": 0 }, "envelope": { "factory": { "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinateSequenceFactory": { "ordinates": 0 } }, "userData": {}, "srid": 0, "ogcGeometryType": 1, "precisionModel": { "scale": 0, "precisionModelType": 0 }, "coordinate": { "x": 0, "y": 0, "z": 0, "m": 0 }, "dimension": 0, "boundaryDimension": 0, "envelopeInternal": { "centre": { "x": 0, "y": 0, "z": 0, "m": 0 } } }, "envelopeInternal": { "centre": { "x": 0, "y": 0, "z": 0, "m": 0 } } }
My question is how can i post on this parameters. It is my first time to use geometry in my app.
Saturday, February 22, 2020 1:53 PM -
User-474980206 posted
to use the Geometry object directly you will need to learn it. also if converting to JSON be sue to use a library that works correctly. see:
https://github.com/NetTopologySuite/NetTopologySuite.IO.GeoJSON
then the client can deserialize with the above library and use the their api to modify the object.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, February 23, 2020 5:37 PM