I try to convert from WellKnownBinary and CoordinateSystemId to obtain the latitude and longitude.
I have a custom class named GeometriaDTO:
GeometriaDTO geoDTO = oInstDTO.Geometria;
DbGeography DBGeo = DbGeography.FromBinary(geoDTO.WellKnownBinary,(int) geoDTO.SRID);
But the last line throw the next error:
An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll but was not handled in user code
I'm going to do this:
double? latitude = DBGeo.Latitude;
double? longitude = DBGeo.Longitude;
How should convert to longitude and latitude?
Thanks in advance.
I resolve the question. I was using the Class DbGeography instead of DbGeometry. The correct implementation is:
GeometriaDTO geoDTO = oInstDTO.Geometria;
DbGeometry DBGeo=DbGeometry.FromBinary(geoDTO.WellKnownBinary, (int)geoDTO.SRID);
double? latitude = DBGeo.XCoordinate;
double? longitude = DBGeo.YCoordinate;
I hope that it will be useful to someone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.