7

I'm looking for a FREE C# class, library or set of functions that will allow me to generate a geodesic linestring (or array of vertices, whatever) from two decimal degree points.

I've found javascript functions that do what I want, but no luck with C# ones.

I suppose I could translate it from the above javascript. But I'd prefer to use something tried and tested.

Anyone know of such functions, classes or libraries?

CaptDragon
  • 13,313
  • 6
  • 55
  • 96

3 Answers3

3

The pe.dll available with the free download of ArcGIS Explorer can be used to do this.

See Exploiting the ESRI Projection Engine (second edition) for discussion.

Kirk Kuykendall
  • 25,787
  • 8
  • 65
  • 153
  • pe.dll doesn't seem to be .NET assembly or COM component because I get this when I try to "Add Reference" to it. – CaptDragon Jun 28 '12 at 17:18
  • Right, it's a good ol fashioned C style dll. Did you download Richie's sample app from arcscripts? It shows how to call this kind of dll. – Kirk Kuykendall Jun 28 '12 at 17:47
  • The first edition of that blog post covers the late binding to pe.dll: http://kiwigis.blogspot.com/2009/05/exploiting-esri-projection-engine.html. – Jay Cummins Jun 28 '12 at 17:50
  • @Kirk I looked through the code and did not see anything that would give me a geodesic line or vertices. It only gives geodesic distance, azimuth and a single coordinate. I need a LINE or array of vertices that represents the geodesic line. – CaptDragon Jun 28 '12 at 17:52
  • What if you find the distance first, then iteratively step towards the TO point via the azimuth function by some fraction of that distance, collecting coordinates in a list as you go? – Kirk Kuykendall Jun 28 '12 at 19:50
  • Forgot to add that at each iteration call GetGeodesicCoordinate with a small fraction of the total distance. – Kirk Kuykendall Jun 28 '12 at 20:03
  • Thanks for putting forth the effort, but I don't think pe.dll is what i'm looking for. My code is made to run on a server and This looks like it rely's on ESRI's ArcGIS Explorer being installed by calling registry Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\E2\CoreRuntime", false); I'd prefer a straight forward C# library or COM object that I can simply drop into my project and start using. If this is my only choice, i'll revisit it. – CaptDragon Jun 28 '12 at 20:19
  • That's the default install location for the pe.dll. Technically, you should be able to put it somewhere else and not rely on the registry. Legally though, I think there's a restriction on unbundling pe.dll from ArcGIS Explorer. There are lots of ArcGIS servers on the web that expose (by default) the Geometry service. Using webclient, you could make an asynchronous call to one of these via the REST Densify API call. – Kirk Kuykendall Jun 28 '12 at 20:55
  • Again, Thanks but ONLY a library I can embed will work. I have to call this many times per user request (time sensitive) withing a loop so I cannot call external web service. I only wish they had that Densify within a DLL I could legaly use, it would be perfect. – CaptDragon Jun 29 '12 at 19:00
1

A few resources for different languages (except C#) are listed here: http://trac.osgeo.org/proj/wiki/GeodesicCalculations

One of them is a PROJ.4 utility geod, which probably has some underlying API. Check out Proj4Net, but I've never used it, and I'm not sure how mature or complete it is.

Mike T
  • 42,095
  • 10
  • 126
  • 187
0

Sorry I can't be more helpful, I can only point in the direction of possibilities, not having had to calculate Geodesics myself.

One option I just found via NuGet System.Spatial

Another option might be one of the ports of JTS to C#. One of these is (can't remember, there is another one as well...http://code.google.com/p/nettopologysuite/

Another .NET spatial library is http://dotspatial.codeplex.com

Yet another option may be http://sqlspatialtools.codeplex.com/ in combination with Microsoft.SqlServer.Spatial.Types assembly. There is a Nuget package of the same name and it comes built in with Sql Server Express (or standard) from version 2008 onwards. Don't be fooled by the Sql Server name though, you might have to use Sql Server types, but you can do spatial operations entirely within code. Pretty limited though, especially projection wise.

All of the above have NuGet packages, so load em up, and try em out. Unfortunately, none of these is really obvious how to get the geometry of a geodesic, but with some projection love, I reckon it would be doable.

My thinking, although it may well be wrong, would be (using perhaps the System.Spatial) to create the line as a Geography type, then reproject to your target geometry type SRID. My knowledge of Geodesics is foggy at best though.

Kelso
  • 1,916
  • 13
  • 20