I am using the most current C# in VS2017 along with the most current DotSpatial packages from Nuget. (Dotspatial with the NetTopologySuite along with the DotSpatial proj4 port)
Given a map of the world and a lat/long position. I want to put a x meter circle around the position.
Currently I am doing the exact same thing using postGres's GIS extensions and it works just fine. But I'd rather not have to talk to a server in order to do this.
I would have thought this would be a simple operation but the results I keep getting back don't make any sense. I would have thought given a lat/long position I would be getting the circle back in lat/long coordinates but that isn't what I'm getting back. I've been trying to re-project them but either I get back a bunch of decidedly NOT lat/long coordinates or a bunch of pairs of Infinity/Infinity. Neither of which I am looking for.
I thought perhaps I might need to reproject them or something but reprojecting doesn't seem to be helping either. I'm not sure what I'm doing wrong.
Unfortunately the DotSpatial documentation leaves a bit to be desired and apparently my googleFu isn't strong enough to find the answer I seek. Can anyone help me make sense of this?
For my test case the lat/long I am using is the coordinates of Disney World in Florida.
lat/long(28.417839, -81.581235)
What I have tried:
My most recent attempt:
var xPosition = -81.581235;
var yPosition = 28.417839;
var precisionModel = new PrecisionModel(PrecisionModelType.Floating);
var factory = new GeometryFactory(precisionModel, 4326);
var position = new Position(new Longitude(xPosition), new Latitude(yPosition));
var point = factory.CreatePoint(new Coordinate(position.Longitude.DecimalDegrees, position.Latitude.DecimalDegrees));
var buffer = point.Buffer(500);
this gives me an IGeometry polygon of 33 coordinates
(418.418765, 28.417839)
(408.811405201615, -69.1273220080641)
(380.358531255643, -162.923877182545)
(334.153571151273, -249.367277509801)
(271.972155593274, -325.135551593274)
(196.203881509801, -387.316967151273)
(109.760481182545, -433.521927255643)
(15.9639260080642, -461.974801201615)
(-81.581235, -471.582161)
(-179.126396008064, -461.974801201615)
(-272.922951182545, -433.521927255643)
(-359.366351509801, -387.316967151273)
(-435.134625593274, -325.135551593274)
(-497.316041151273, -249.367277509801)
(-543.521001255643, -162.923877182545)
(-571.973875201615, -69.1273220080639)
(-581.581235, 28.4178390000004)
(-571.973875201615, 125.963000008065)
(-543.521001255643, 219.759555182545)
(-497.316041151272, 306.202955509802)
(-435.134625593273, 381.971229593274)
(-359.3663515098, 444.152645151273)
(-272.922951182544, 490.357605255644)
(-179.126396008063, 518.810479201615)
(-81.5812349999988, 528.417839)
(15.9639260080655, 518.810479201615)
(109.760481182546, 490.357605255643)
(196.203881509802, 444.152645151272)
(271.972155593275, 381.971229593273)
(334.153571151274, 306.2029555098)
(380.358531255644, 219.759555182543)
(408.811405201616, 125.963000008062)
(418.418765, 28.417839)
This would be fine... if they were latitude/longitude coordinates. I don't know what they are, but they're not lat/long on this planet.
Figuring I needed to reproject (but not knowing what the original projection is) I did some googling and found this (among many others):
var pointArray = new List<double>();
var zArray = new double[1] { 0 };
for (var index = 0; index < buffer.Coordinates.Count(); index++)
{
var coordinate = buffer.Coordinates[index];
pointArray.Add(coordinate.X);
pointArray.Add(coordinate.Y);
}
var oldProjection = new DotSpatial.Projections.ProjectionInfo();
var newProjection = KnownCoordinateSystems.Geographic.World.WGS1984;
DotSpatial.Projections.Reproject.ReprojectPoints(pointArray.ToArray(), zArray, oldProjection, newProjection, 0, pointArray.Count / 2);
for (var index = 0; index < buffer.Coordinates.Count(); index++)
{
var coordinate = buffer.Coordinates[index];
coordinate.X = pointArray[index];
coordinate.Y = pointArray[index + 1];
}
But this isn't giving me latitude and longitude either. Example:
(418.418765, 28.417839)
(28.417839, 408.811405201615)
(408.811405201615, -69.1273220080641)
(-69.1273220080641, 380.358531255643)
(380.358531255643, -162.923877182545)
(-162.923877182545, 334.153571151273