├── .gitignore ├── Docs ├── CommonWellKnownText.md ├── CreateCSByCode.md ├── CreateCSByWKT.md ├── CreateProjection.md ├── LoadByID.md ├── README.md ├── Supported projections.md └── Well-Known Text.md ├── LICENSE ├── README.md └── src ├── ProjNET.Tests ├── CoordinateTransformTests.cs ├── ProjNET.Tests.csproj ├── SRID.csv ├── SRIDReader.cs └── WKT │ └── WKTCoordSysParserTests.cs ├── ProjNET.sln └── ProjNET ├── CoordinateSystems ├── AngularUnit.cs ├── AxisInfo.cs ├── AxisOrientationEnum.cs ├── CoordinateSystem.cs ├── CoordinateSystemFactory.cs ├── Datum.cs ├── DatumType.cs ├── Ellipsoid.cs ├── GeocentricCoordinateSystem.cs ├── GeographicCoordinateSystem.cs ├── GeographicTransform.cs ├── HorizontalCoordinateSystem.cs ├── HorizontalDatum.cs ├── IAngularUnit.cs ├── ICompoundCoordinateSystem.cs ├── ICoordinateSystem.cs ├── ICoordinateSystemFactory.cs ├── IDatum.cs ├── IEllipsoid.cs ├── IFittedCoordinateSystem.cs ├── IGeocentricCoordinateSystem.cs ├── IGeodeticSpatialReference.cs ├── IGeographicCoordinateSystem.cs ├── IGeographicTransform.cs ├── IHorizontalCoordinateSystem.cs ├── IHorizontalDatum.cs ├── IInfo.cs ├── ILinearUnit.cs ├── ILocalCoordinateSystem.cs ├── ILocalDatum.cs ├── IParameterInfo.cs ├── IPrimeMeridian.cs ├── IProjectedCoordinateSystem.cs ├── IProjection.cs ├── IUnit.cs ├── IVerticalCoordinateSystem.cs ├── IVerticalDatum.cs ├── Info.cs ├── LinearUnit.cs ├── Parameter.cs ├── PrimeMeridian.cs ├── ProjectedCoordinateSystem.cs ├── Projection.cs ├── ProjectionParameter.cs ├── Projections │ ├── AlbersProjection.cs │ ├── KrovakProjection.cs │ ├── LambertConformalConic.cs │ ├── MapProjection.cs │ ├── Mercator.cs │ └── TransverseMercator.cs ├── Transformations │ ├── ConcatenatedTransform.cs │ ├── CoordinateTransformation.cs │ ├── CoordinateTransformationAuthorityFactory.cs │ ├── CoordinateTransformationFactory.cs │ ├── DatumTransform.cs │ ├── DomainFlags.cs │ ├── GeocentricTransform.cs │ ├── GeographicTransform.cs │ ├── ICoordinateSystemAuthorityFactory.cs │ ├── ICoordinateTransformation.cs │ ├── ICoordinateTransformationAuthorityFactory.cs │ ├── ICoordinateTransformationFactory.cs │ ├── IMathTransform.cs │ ├── IMathTransformFactory.cs │ ├── MathTransform.cs │ └── TransformType.cs ├── Unit.cs └── WGS84ConversionInfo.cs ├── IO └── CoordinateSystems │ ├── CoordinateSystemWktReader.cs │ ├── StreamTokenizer.cs │ ├── TokenType.cs │ └── WKTStreamTokenizer.cs └── ProjNET.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /Docs/CommonWellKnownText.md: -------------------------------------------------------------------------------- 1 | ### Popular Well-Known Text representations of Spatial Reference Systems 2 | 3 | Here a some of the most common WKTs. See SRID.CSV in the release for more, 4 | 5 | #### WGS 84 geographic coordinate system 6 | ``` 7 | GEOGCS["GCS_WGS_1984", 8 | DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563](_D_WGS_1984_,SPHEROID[_WGS_1984_,6378137,298.257223563)], 9 | PRIMEM["Greenwich",0](_Greenwich_,0), 10 | UNIT["Degree",0.0174532925199433](_Degree_,0.0174532925199433) 11 | ] 12 | ``` 13 | 14 | #### Universal Transverse Mercator - WGS84 based 15 | This sample includes Authority numbers. These are not strictly necessary but good practice to include. 16 | ``` 17 | PROJCS["WGS 84 / UTM zone 32N", 18 | GEOGCS["WGS 84", 19 | DATUM["WGS_1984", 20 | SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"](_WGS-84_,6378137,298.257223563,AUTHORITY[_EPSG_,_7030_)], 21 | AUTHORITY["EPSG","6326"](_EPSG_,_6326_) 22 | ], 23 | PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"](_Greenwich_,0,AUTHORITY[_EPSG_,_8901_)], 24 | UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"](_degree_,0.01745329251994328,AUTHORITY[_EPSG_,_9122_)], 25 | AUTHORITY["EPSG","4326"](_EPSG_,_4326_) 26 | ], 27 | PROJECTION["Transverse_Mercator"](_Transverse_Mercator_), 28 | PARAMETER["latitude_of_origin",0](_latitude_of_origin_,0), 29 | PARAMETER["central_meridian",9](_central_meridian_,9), 30 | PARAMETER["scale_factor",0.9996](_scale_factor_,0.9996), 31 | PARAMETER["false_easting",500000](_false_easting_,500000), 32 | PARAMETER["false_northing",0](_false_northing_,0), 33 | UNIT["metre",1,AUTHORITY["EPSG","9001"](_metre_,1,AUTHORITY[_EPSG_,_9001_)], 34 | AUTHORITY["EPSG","32632"](_EPSG_,_32632_) 35 | ] 36 | ``` 37 | This example is for zone 32N. To create for other zones, change the following: 38 | * central_meridian = ZoneNumber * 6 - 183 39 | * false_northing: 0 for North, 10000000 for South. 40 | * Last EPSG number for projection = (32600 + Zone) and add 100 more if zone is south. 41 | 42 | #### [Microsoft Virtual Earth](http://maps.live.com) / [Google Maps](http://maps.google.com) Mercator Projection 43 | ``` 44 | PROJCS["Popular Visualisation CRS / Mercator", 45 | GEOGCS["Popular Visualisation CRS", 46 | DATUM["Popular Visualisation Datum", 47 | SPHEROID["Popular Visualisation Sphere", 6378137, 0, AUTHORITY["EPSG",7059](_Popular-Visualisation-Sphere_,-6378137,-0,-AUTHORITY[_EPSG_,7059)], 48 | TOWGS84[0, 0, 0, 0, 0, 0, 0](0,-0,-0,-0,-0,-0,-0), AUTHORITY["EPSG",6055](_EPSG_,6055) 49 | ], 50 | PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"](_Greenwich_,-0,-AUTHORITY[_EPSG_,-_8901_)], 51 | UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9102"](_degree_,-0.0174532925199433,-AUTHORITY[_EPSG_,-_9102_)], 52 | AXIS["E", EAST](_E_,-EAST), 53 | AXIS["N", NORTH](_N_,-NORTH), 54 | AUTHORITY["EPSG",4055](_EPSG_,4055) 55 | ], 56 | PROJECTION["Mercator"](_Mercator_), 57 | PARAMETER["False_Easting", 0](_False_Easting_,-0), 58 | PARAMETER["False_Northing", 0](_False_Northing_,-0), 59 | PARAMETER["Central_Meridian", 0](_Central_Meridian_,-0), 60 | PARAMETER["Latitude_of_origin", 0](_Latitude_of_origin_,-0), 61 | UNIT["metre", 1, AUTHORITY["EPSG", "9001"](_metre_,-1,-AUTHORITY[_EPSG_,-_9001_)], 62 | AXIS["East", EAST](_East_,-EAST), 63 | AXIS["North", NORTH](_North_,-NORTH), 64 | AUTHORITY["EPSG",3785](_EPSG_,3785) 65 | ] 66 | ``` 67 | *Note that this is the projection they use for display, but geometry input/output is using WGS84 geographic. -------------------------------------------------------------------------------- /Docs/CreateCSByCode.md: -------------------------------------------------------------------------------- 1 | ### Constructing a Coordinate System by code 2 | Creating a coordinate system by code is a little more tedious than [constructing it from Well-known text](CreateCSByWKT) or [create it by an SRID](LoadByID). 3 | It also requires you to know all the parameters for the coordinate system, but on the other hand it gives you the power to construct any spatial reference where no WKT or SRID exists. 4 | 5 | To create a coordinate system, you first need to create a Coordinate System factory: 6 | ```cs 7 | CoordinateSystemFactory cFac = new ProjNET.CoordinateSystems.CoordinateSystemFactory(); 8 | ``` 9 | #### Creating a geographic coordinate system 10 | A geographic coordinate system consists of the following: 11 | * A prime meridian (usually Greenwich) 12 | * A datum 13 | * An ellipsoid (in the datum) 14 | * An angular unit (usually degrees) 15 | * A couple of axis (usually Latitude/Longitude) 16 | ```cs 17 | //Create Bessel 1840 geographic coordinate system 18 | IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); 19 | IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); 20 | IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, 21 | PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), 22 | new AxisInfo("Lat", AxisOrientationEnum.North)); 23 | ``` 24 | The are a number of predefined common geographic coordinate systems you can use. Example: 25 | ``` 26 | GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84; 27 | ``` 28 | #### Creating a projected coordinate system 29 | A projected coordinate system consists of the following: 30 | * A geographic coordinate system 31 | * A projection 32 | * A linear unit 33 | * A set of axes 34 | The projection contains a projection type (see WKT name in "[Supported projections](Supported-projections)") and a set of parameters. 35 | 36 | ```cs 37 | //Create World Mercator projected coordinate system 38 | List parameters = new List(4); 39 | parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); 40 | parameters.Add(new ProjectionParameter("central_meridian", 0)); 41 | parameters.Add(new ProjectionParameter("false_easting", 0)); 42 | parameters.Add(new ProjectionParameter("false_northing", 0)); 43 | IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); 44 | IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("World Mercator WGS84", 45 | GeographicCoordinateSystem.WGS84, projection, LinearUnit.Metre, 46 | new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); 47 | ``` 48 | The projection CS class comes with a helper method for defining a WGS84 based Universal Transverse Mercator (UTM) projection, by specifying a UTM zone and northern/southern hemisphere: 49 | ```cs 50 | IProjectedCoordinateSystem UTM32N = ProjectedCoordinateSystem.WGS84_UTM(32,true) 51 | ``` 52 | #### Converting a coordinate system to a string representation 53 | Once a coordinate system has been created, you can easily convert the projection into a readable Well-known text, by using its WKT property: 54 | ```cs 55 | string WellKnownText = coordsys.WKT; 56 | ``` 57 | Similarly you can get the OGC XML representation using 58 | ```cs 59 | string csXML = coordsys.XML; 60 | ``` -------------------------------------------------------------------------------- /Docs/CreateCSByWKT.md: -------------------------------------------------------------------------------- 1 | ### Constructing a Coordinate System (CS) by Well-known Text (WKT) 2 | ```cs 3 | string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563](__GCS_WGS_1984__,DATUM[__D_WGS_1984__,SPHEROID[__WGS_1984__,6378137,298.257223563)],PRIMEM[\"Greenwich\",0](__Greenwich__,0),UNIT[\"Degree\",0.0174532925199433](__Degree__,0.0174532925199433)]"; 4 | ICoordinateSystem cs = ProjNET.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt) as ICoordinateSystem; 5 | ``` 6 | If you know that the WKT is for instance a geographic coordinate system as above, you can instead cast it to that if necessary: 7 | ```cs 8 | IGeographicCoordinateSystem gcs = CoordinateSystemWktReader.Parse(wkt_geo) as IGeographicCoordinateSystem; 9 | ``` 10 | and similar for a projected coordinate system: 11 | ```cs 12 | IProjectedCoordinateSystem pcs = CoordinateSystemWktReader.Parse(wkt_proj) as IProjectedCoordinateSystem; 13 | ``` -------------------------------------------------------------------------------- /Docs/CreateProjection.md: -------------------------------------------------------------------------------- 1 | ### Projecting points from one coordinate system to another 2 | Performing a transformation from one coordinate system to another requires you to create two coordinate systems: A '_from_' and a '_to_' coordinate system. See [the FAQ](FAQ) on how to create a coordinate system. 3 | 4 | First create a CoordinateTransformationFactory: 5 | ```cs 6 | CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); 7 | ``` 8 | Then create the transformation instance: 9 | ```cs 10 | ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(fromCS, toCS); 11 | ``` 12 | All transformations are done on double arrays, where the first value is primary axis (X/East/Latitude) and the second the secondary (Y/North/Longitude). You can provide an optional third value (Z/Height), which can change if a datum transformation occurs* during the transform. 13 | Example: 14 | ```cs 15 | double[]()() fromPoint = new double[]()() { 120, -3 }; 16 | double[]() toPoint = trans.MathTransform.Transform(fromPoint); 17 | ``` 18 | If you want to transform back again, create an inversed transformation: 19 | ```cs 20 | IMathTransform inversedTransform = trans.MathTransform.Inverse(); 21 | double[]() point = inversedTransform.Transform(toPoint); 22 | ``` 23 | 24 | *Note that no datum transformation is applied if the coordinate systems doesn't have a ToWGS84 parameter defined. -------------------------------------------------------------------------------- /Docs/LoadByID.md: -------------------------------------------------------------------------------- 1 | ### Loading a projection by Spatial Reference ID (SRID) 2 | Proj.NET doesn't have an embedded Spatial Reference ID database like the [EPSG database](http://www.epsg.org/Geodetic.html), so there is no default logic for loading a spatial reference by ID. 3 | However Proj.NET does ship with a comma-separated file with EPSG codes, and you can easily iterate through these to load a specific ID. This is not as efficient as loading the data from an indexed database, but it's simple and easy to deploy. 4 | 5 | Below is a simple class for loading a coordinate system by SRID. 6 | 7 | ```cs 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | using ProjNET.CoordinateSystems; 12 | public class SridReader 13 | { 14 | private static string filename = "SRID.csv"; //Change this to point to the SRID.CSV file. 15 | 16 | public struct WKTstring { 17 | /// Well-known ID 18 | public int WKID; 19 | /// Well-known Text 20 | public string WKT; 21 | } 22 | 23 | /// Enumerates all SRID's in the SRID.csv file. 24 | /// Enumerator 25 | public static IEnumerable GetSRIDs() 26 | { 27 | using (System.IO.StreamReader sr = System.IO.File.OpenText(filename)) 28 | { 29 | while (!sr.EndOfStream) 30 | { 31 | string line = sr.ReadLine(); 32 | int split = line.IndexOf(';'); 33 | if (split > -1) 34 | { 35 | WKTstring wkt = new WKTstring(); 36 | wkt.WKID = int.Parse(line.Substring(0, split)); 37 | wkt.WKT = line.Substring(split + 1); 38 | yield return wkt; 39 | } 40 | } 41 | sr.Close(); 42 | } 43 | } 44 | /// Gets a coordinate system from the SRID.csv file 45 | /// EPSG ID 46 | /// Coordinate system, or null if SRID was not found. 47 | public static ICoordinateSystem GetCSbyID(int id) 48 | { 49 | foreach (SridReader.WKTstring wkt in SridReader.GetSRIDs()) 50 | { 51 | if (wkt.WKID == id) //We found it! 52 | { 53 | return ProjNET.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt.WKT) as ICoordinateSystem; 54 | } 55 | } 56 | return null; 57 | } 58 | } 59 | ``` 60 | 61 | Loading a CS by ID is then as simple as: 62 | ```cs 63 | ICoordinateSystem cs = SridReader.GetCSbyID(4326); 64 | ``` 65 | 66 | The demo website also shows how to use this approach. 67 | 68 | For better performance I would recommend changing the "GetCSbyID()" method to connect to a database and query for the WKT by SRID. The .CSV file should be fairly easy to import into the database. -------------------------------------------------------------------------------- /Docs/README.md: -------------------------------------------------------------------------------- 1 | ### Frequently Asked Questions 2 | 3 | * [Introduction to Coordinate Systems](https://www.xaml.dev/post/Spatial-references2c-coordinate-systems2c-projections2c-datums2c-ellipsoids-e28093-confusing) 4 | * [Constructing a Coordinate System (CS) by Well-known Text (WKT)](CreateCSByWKT) 5 | * [Loading a projection by Spatial Reference ID (SRID)](LoadByID) 6 | * [Constructing a Coordinate System by code](CreateCSByCode) 7 | * [Projecting points from one Coordinate System to another](CreateProjection) -------------------------------------------------------------------------------- /Docs/Supported projections.md: -------------------------------------------------------------------------------- 1 | ### Supported projections 2 | 3 | 4 | 5 | | Projection | Description | WKT name | 6 | | :------------- | :----------: | -----------: | 7 | | Mercator 1-standard parallel and Mercator 2-standard parallels | This map projection introduced in 1569 by Gerardus Mercator. It is often described as a cylindrical projection, but it must be derived mathematically. The meridians are equally spaced, parallel vertical lines, and the parallels of latitude are parallel, horizontal straight lines, spaced farther and farther apart as their distance from the Equator increases. This projection is widely used for navigation charts, because any straight line on a Mercator-projection map is a line of constant true bearing that enables a navigator to plot a straight-line course. It is less practical for world maps because the scale is distorted; areas farther away from the equator appear disproportionately large. On a Mercator projection, for example, the landmass of Greenland appears to be greater than that of the continent of South America; in actual area, Greenland is smaller than the Arabian Peninsula. | `mercator`, `mercator_1sp`, `mercator_2sp` | 8 | | Transverse mercator | Universal (UTM) and Modified (MTM) Transverses Mercator projections. This is a cylindrical projection, in which the cylinder has been rotated 90°. Instead of being tangent to the equator (or to an other standard latitude), it is tangent to a central meridian. Deformation are more important as we are going futher from the central meridian. The Transverse Mercator projection is appropriate for region wich have a greater extent north-south than east-west. | `transverse_mercator` | 9 | | Lambert Conic Conformal 2-standard parallel | The Lambert Conformal Conic projection is a standard projection for presenting maps of land areas whose East-West extent is large compared with their North-South extent. This projection is "conformal" in the sense that lines of latitude and longitude, which are perpendicular to one another on the earth's surface, are also perpendicular to one another in the projected domain. | `lambert_conformal_conic`, `lambert_conformal_conic_2sp`, `lambert_conic_conformal_(2sp)` | 10 | | Albers | The Albers projection is most commonly used to project the United States of America. It gives the northern border with Canada a curved appearance. | `albers`, `albers_conic_equal_area` | 11 | 12 | 13 | 14 | #### Pseudo-Plate Carré 15 | 16 | Longitude and Latitude are projected directly to image-space by only applying a scale: 17 | 18 | ![Supported projections_pseudoPlateCarree](https://user-images.githubusercontent.com/1378165/87069115-81e4d180-c1cb-11ea-9e0b-07869cbe8894.gif) 19 | 20 | 21 | #### Mercator projection 22 | 23 | ![Supported projections_mercator](https://user-images.githubusercontent.com/1378165/87069142-8b6e3980-c1cb-11ea-9ea2-6517f07cf31a.gif) 24 | 25 | 26 | 27 | #### Lambert and Albers compared 28 | 29 | ![Supported projections_lambert_albers](https://user-images.githubusercontent.com/1378165/87069158-91641a80-c1cb-11ea-9b53-8e57eaf00b96.gif) 30 | -------------------------------------------------------------------------------- /Docs/Well-Known Text.md: -------------------------------------------------------------------------------- 1 | ### Well-Known Text Representation of Spatial Reference Systems 2 | The WKT Format provides a standard textual representation for spatial reference system information. The definitions of the well-known text representations are modeled after the POSC/EPSG coordinate data. 3 | 4 | The following description is from the "[OpenGIS® Simple Features Implementation Specification for OLE/COM version 1.1](http://www.opengeospatial.org/standards/sfo)" 5 | 6 | A spatial reference system, also referred to as a coordinate system, is a geographic (latitude-longitude), a projected (X,Y), or a geocentric (X,Y,Z) coordinate system. 7 | The coordinate system is composed of several objects. Each object has a keyword in upper case (for example, DATUM or UNIT) followed by the defining, comma-delimited, parameters of the object in brackets. Some objects are composed of objects so the result is a nested structure. Implementations are free to substitute standard brackets ( ) for square brackets [ ](-) and should be prepared to read both forms of brackets. 8 | The EBNF (Extended Backus Naur Form) definition for the string representation of a coordinate system is as follows, using square brackets: 9 | ``` 10 | = | | 11 | = PROJCS["", , , {,}* ](__name__,-_geographic-cs_,-_projection_,-{_parameter_,}_-_linear-unit_) 12 | = PROJECTION[""](__name__) 13 | = PARAMETER["", ](__name__,-_value_) 14 | = 15 | ``` 16 | A data set's coordinate system is identified by the PROJCS keyword if the data are in projected coordinates, by GEOGCS if in geographic coordinates, or by GEOCCS if in geocentric coordinates. 17 | The PROJCS keyword is followed by all of the "pieces" which define the projected coordinate system. The first piece of any object is always the name. Several objects follow the projected coordinate system name: the geographic coordinate system, the map projection, 1 or more parameters, and the linear unit of measure. All projected coordinate systems are based upon a geographic coordinate system so we will describe the pieces specific to a projected coordinate system first. As an example, UTM zone 10N on the NAD83 datum is defined as: 18 | ``` 19 | PROJCS["NAD_1983_UTM_Zone_10N", 20 | , 21 | PROJECTION["Transverse_Mercator"](_Transverse_Mercator_), 22 | PARAMETER["False_Easting",500000.0](_False_Easting_,500000.0), 23 | PARAMETER["False_Northing",0.0](_False_Northing_,0.0), 24 | PARAMETER["Central_Meridian",-123.0](_Central_Meridian_,-123.0), 25 | PARAMETER["Scale_Factor",0.9996](_Scale_Factor_,0.9996), 26 | PARAMETER["Latitude_of_Origin",0.0](_Latitude_of_Origin_,0.0), 27 | UNIT["Meter",1.0](_Meter_,1.0) 28 | ] 29 | ``` 30 | The name and several objects define the geographic coordinate system object in turn: the datum, the prime meridian, and the angular unit of measure. 31 | ``` 32 | = GEOGCS["", , , ](__name__,-_datum_,-_prime-meridian_,-_angular-unit_) 33 | = DATUM["", ](__name__,-_spheroid_) 34 | = SPHEROID["", , ](__name__,-_semi-major-axis_,-_inverse-flattening_) 35 | = NOTE: semi-major axis is measured in meters and must be > 0. 36 | = 37 | = PRIMEM["", ](__name__,-_longitude_) 38 | = 39 | ``` 40 | The geographic coordinate system string for UTM zone 10 on NAD83 is 41 | ``` 42 | GEOGCS["GCS_North_American_1983", 43 | DATUM["D_North_American_1983", 44 | SPHEROID["GRS_1980",6378137,298.257222101](_GRS_1980_,6378137,298.257222101)], 45 | PRIMEM["Greenwich",0](_Greenwich_,0), 46 | UNIT["Degree",0.0174532925199433](_Degree_,0.0174532925199433)] 47 | ``` 48 | The UNIT object can represent angular or linear unit of measures. 49 | ``` 50 | = 51 | = 52 | = UNIT["", ](__name__,-_conversion-factor_) 53 | = 54 | ``` 55 | specifies number of meters (for a linear unit) or number of radians (for an angular unit) per unit and must be greater than zero. 56 | So the full string representation of UTM Zone 10N is 57 | ``` 58 | PROJCS["NAD_1983_UTM_Zone_10N", 59 | GEOGCS["GCS_North_American_1983", 60 | DATUM[ "D_North_American_1983", 61 | SPHEROID["GRS_1980",6378137,298.257222101](_GRS_1980_,6378137,298.257222101) 62 | ], 63 | PRIMEM["Greenwich",0](_Greenwich_,0), 64 | UNIT["Degree",0.0174532925199433](_Degree_,0.0174532925199433) 65 | ], 66 | PROJECTION["Transverse_Mercator"](_Transverse_Mercator_), 67 | PARAMETER["False_Easting",500000.0](_False_Easting_,500000.0), 68 | PARAMETER["False_Northing",0.0](_False_Northing_,0.0), 69 | PARAMETER["Central_Meridian",-123.0](_Central_Meridian_,-123.0), 70 | PARAMETER["Scale_Factor",0.9996](_Scale_Factor_,0.9996), 71 | PARAMETER["Latitude_of_Origin",0.0](_Latitude_of_Origin_,0.0), 72 | UNIT["Meter",1.0](_Meter_,1.0) 73 | ] 74 | ``` 75 | A geocentric coordinate system is quite similar to a geographic coordinate system. It is represented by 76 | ``` 77 | = GEOCCS["", , , ](__name__,-_datum_,-_prime-meridian_,-_linear-unit_) 78 | ``` 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Morten Nielsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Not maintained 2 | This project was previously hosted on CodePlex - I merely moved this to GitHub and made sure it'll build with latest Visual Studio. 3 | Beyond that, this project isn't currently maintained. 4 | 5 | ## .NET Spatial Reference and Projection Engine 6 | Proj.NET performs point-to-point coordinate conversions between geodetic coordinate systems for use in fx. Geographic Information Systems (GIS) or GPS applications. The spatial reference model used adheres to the [Simple Features specification](http://www.opengeospatial.org/standards/sfo). 7 | 8 | * [Read the FAQ](Docs/README.md) for common questions. 9 | * [Popular Well-Known Text representations for Spatial Reference Systems](Docs/Well-Known%20Text.md) 10 | 11 | ### Supports 12 | * Datum transformations 13 | * Geographic, Geocentric, and Projected coordinate systems 14 | * .NET Standard 1.0, so will run with any .NET Standard 1.0 complaint framework (ie all of them!) 15 | * Converts coordinate systems to/from [Well-Known Text](Docs/Well-Known%20Text.md) (WKT) and to XML 16 | 17 | ### Projection types currently supported 18 | * Mercator 19 | * Transverse Mercator 20 | * Albers 21 | * Lambert Conformal 22 | * Krovak 23 | See [Supported projections](Docs/Supported%20projections.md) for details. 24 | 25 | ### Nuget 26 | There's also a package available in the Nuget Gallery, created by Mathieu Cartoixa [Proj.NET 1.2](https://nuget.org/packages/ProjNet) 27 | 28 | ### Resources 29 | For an introduction to spatial reference systems [see here](https://www.xaml.dev/post/Spatial-references2c-coordinate-systems2c-projections2c-datums2c-ellipsoids-e28093-confusing) 30 | 31 | If you're working with Google/Bing/OpenLayers, maybe this blog post can help you: [The Google Maps / Bing Maps Spherical Mercator Projection](http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection) 32 | 33 | -------------------------------------------------------------------------------- /src/ProjNET.Tests/ProjNET.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | PreserveNewest 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/ProjNET.Tests/SRIDReader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using ProjNet.Converters.WellKnownText; 4 | using ProjNet.CoordinateSystems; 5 | 6 | namespace ProjNet.UnitTests 7 | { 8 | internal class SRIDReader 9 | { 10 | private const string filename = @"SRID.csv"; 11 | 12 | public struct WKTstring { 13 | /// 14 | /// Well-known ID 15 | /// 16 | public int WKID; 17 | /// 18 | /// Well-known Text 19 | /// 20 | public string WKT; 21 | } 22 | 23 | /// 24 | /// Enumerates all SRID's in the SRID.csv file. 25 | /// 26 | /// Enumerator 27 | public static IEnumerable GetSRIDs() 28 | { 29 | using (StreamReader sr = File.OpenText(filename)) 30 | { 31 | while (!sr.EndOfStream) 32 | { 33 | string line = sr.ReadLine(); 34 | int split = line.IndexOf(';'); 35 | if (split > -1) 36 | { 37 | WKTstring wkt = new WKTstring(); 38 | wkt.WKID = int.Parse(line.Substring(0, split)); 39 | wkt.WKT = line.Substring(split + 1); 40 | yield return wkt; 41 | } 42 | } 43 | sr.Close(); 44 | } 45 | } 46 | /// 47 | /// Gets a coordinate system from the SRID.csv file 48 | /// 49 | /// EPSG ID 50 | /// Coordinate system, or null if SRID was not found. 51 | public static ICoordinateSystem GetCSbyID(int id) 52 | { 53 | CoordinateSystemFactory fac = new CoordinateSystemFactory(); 54 | foreach (WKTstring wkt in GetSRIDs()) 55 | { 56 | if (wkt.WKID == id) 57 | { 58 | return CoordinateSystemWktReader.Parse(wkt.WKT) as ICoordinateSystem; 59 | } 60 | } 61 | return null; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/ProjNET.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjNET", "ProjNET\ProjNET.csproj", "{E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjNET.Tests", "ProjNET.Tests\ProjNET.Tests.csproj", "{67E8C952-1F48-4DFB-9507-BD44DB6784FD}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|.NET = Debug|.NET 13 | Debug|Any CPU = Debug|Any CPU 14 | Debug|Mixed Platforms = Debug|Mixed Platforms 15 | Release|.NET = Release|.NET 16 | Release|Any CPU = Release|Any CPU 17 | Release|Mixed Platforms = Release|Mixed Platforms 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Debug|.NET.ActiveCfg = Debug|Any CPU 21 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 24 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 25 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Release|.NET.ActiveCfg = Release|Any CPU 26 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 29 | {E028BDD2-55E1-4E5F-BE31-35FAEC8D6428}.Release|Mixed Platforms.Build.0 = Release|Any CPU 30 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Debug|.NET.ActiveCfg = Debug|Any CPU 31 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 34 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 35 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Release|.NET.ActiveCfg = Release|Any CPU 36 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 39 | {67E8C952-1F48-4DFB-9507-BD44DB6784FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU 40 | EndGlobalSection 41 | GlobalSection(SolutionProperties) = preSolution 42 | HideSolutionNode = FALSE 43 | EndGlobalSection 44 | GlobalSection(ExtensibilityGlobals) = postSolution 45 | SolutionGuid = {22925D0E-B7A9-4300-A63B-271B415EB162} 46 | EndGlobalSection 47 | EndGlobal 48 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/AngularUnit.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Globalization; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Definition of angular units. 31 | /// 32 | public class AngularUnit : Info, IAngularUnit 33 | { 34 | /// 35 | /// Initializes a new instance of a angular unit 36 | /// 37 | /// Radians per unit 38 | public AngularUnit(double radiansPerUnit) 39 | : this( 40 | radiansPerUnit,String.Empty,String.Empty,-1,String.Empty,String.Empty,String.Empty) 41 | { 42 | } 43 | 44 | /// 45 | /// Initializes a new instance of a angular unit 46 | /// 47 | /// Radians per unit 48 | /// Name 49 | /// Authority name 50 | /// Authority-specific identification code. 51 | /// Alias 52 | /// Abbreviation 53 | /// Provider-supplied remarks 54 | internal AngularUnit(double radiansPerUnit, string name, string authority, long authorityCode, string alias, string abbreviation, string remarks) 55 | : 56 | base(name, authority, authorityCode, alias, abbreviation, remarks) 57 | { 58 | _RadiansPerUnit = radiansPerUnit; 59 | } 60 | 61 | #region Predifined units 62 | 63 | /// 64 | /// The angular degrees are PI/180 = 0.017453292519943295769236907684886 radians 65 | /// 66 | public static AngularUnit Degrees 67 | { 68 | get { return new AngularUnit(0.017453292519943295769236907684886, "degree", "EPSG", 9102, "deg", String.Empty, "=pi/180 radians"); } 69 | } 70 | 71 | /// 72 | /// SI standard unit 73 | /// 74 | public static AngularUnit Radian 75 | { 76 | get { return new AngularUnit(1, "radian", "EPSG", 9101, "rad", String.Empty, "SI standard unit."); } 77 | } 78 | 79 | /// 80 | /// Pi / 200 = 0.015707963267948966192313216916398 radians 81 | /// 82 | public static AngularUnit Grad 83 | { 84 | get { return new AngularUnit(0.015707963267948966192313216916398, "grad", "EPSG", 9105, "gr", String.Empty, "=pi/200 radians."); } 85 | } 86 | 87 | /// 88 | /// Pi / 200 = 0.015707963267948966192313216916398 radians 89 | /// 90 | public static AngularUnit Gon 91 | { 92 | get { return new AngularUnit(0.015707963267948966192313216916398, "gon", "EPSG", 9106, "g", String.Empty, "=pi/200 radians."); } 93 | } 94 | #endregion 95 | 96 | #region IAngularUnit Members 97 | 98 | private double _RadiansPerUnit; 99 | 100 | /// 101 | /// Gets or sets the number of radians per . 102 | /// 103 | public double RadiansPerUnit 104 | { 105 | get { return _RadiansPerUnit; } 106 | set { _RadiansPerUnit = value; } 107 | } 108 | 109 | /// 110 | /// Returns the Well-known text for this object 111 | /// as defined in the simple features specification. 112 | /// 113 | public override string WKT 114 | { 115 | get 116 | { 117 | StringBuilder sb = new StringBuilder(); 118 | sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat,"UNIT[\"{0}\", {1}", Name, RadiansPerUnit); 119 | if (!String.IsNullOrEmpty(Authority) && AuthorityCode > 0) 120 | sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); 121 | sb.Append("]"); 122 | return sb.ToString(); 123 | } 124 | } 125 | 126 | /// 127 | /// Gets an XML representation of this object. 128 | /// 129 | public override string XML 130 | { 131 | get 132 | { 133 | return String.Format(CultureInfo.InvariantCulture.NumberFormat, "{1}", RadiansPerUnit, InfoXml); 134 | } 135 | } 136 | 137 | #endregion 138 | 139 | /// 140 | /// Checks whether the values of this instance is equal to the values of another instance. 141 | /// Only parameters used for coordinate system are used for comparison. 142 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 143 | /// 144 | /// 145 | /// True if equal 146 | public override bool EqualParams(object obj) 147 | { 148 | if (!(obj is AngularUnit au)) 149 | return false; 150 | return au.RadiansPerUnit == this.RadiansPerUnit; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/AxisInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Details of axis. This is used to label axes, and indicate the orientation. 31 | /// 32 | public class AxisInfo 33 | { 34 | /// 35 | /// Initializes a new instance of an AxisInfo. 36 | /// 37 | /// Name of axis 38 | /// Axis orientation 39 | public AxisInfo(string name, AxisOrientationEnum orientation) 40 | { 41 | _Name = name; 42 | _Orientation = orientation; 43 | } 44 | 45 | private string _Name; 46 | 47 | /// 48 | /// Human readable name for axis. Possible values are X, Y, Long, Lat or any other short string. 49 | /// 50 | public string Name 51 | { 52 | get { return _Name; } 53 | set { _Name = value; } 54 | } 55 | 56 | private AxisOrientationEnum _Orientation; 57 | 58 | /// 59 | /// Gets enumerated value for orientation. 60 | /// 61 | public AxisOrientationEnum Orientation 62 | { 63 | get { return _Orientation; } 64 | set { _Orientation = value; } 65 | } 66 | 67 | /// 68 | /// Returns the Well-known text for this object 69 | /// as defined in the simple features specification. 70 | /// 71 | public string WKT 72 | { 73 | get 74 | { 75 | return String.Format("AXIS[\"{0}\", {1}]", Name, Orientation.ToString().ToUpperInvariant()); 76 | } 77 | } 78 | /// 79 | /// Gets an XML representation of this object 80 | /// 81 | public string XML 82 | { 83 | get 84 | { 85 | return String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "", Name, Orientation.ToString().ToUpperInvariant()); 86 | } 87 | } 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/AxisOrientationEnum.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Orientation of axis. Some coordinate systems use non-standard orientations. 31 | /// For example, the first axis in South African grids usually points West, 32 | /// instead of East. This information is obviously relevant for algorithms 33 | /// converting South African grid coordinates into Lat/Long. 34 | /// 35 | public enum AxisOrientationEnum : short 36 | { 37 | /// 38 | /// Unknown or unspecified axis orientation. This can be used for local or fitted coordinate systems. 39 | /// 40 | Other = 0, 41 | /// 42 | /// Increasing ordinates values go North. This is usually used for Grid Y coordinates and Latitude. 43 | /// 44 | North = 1, 45 | /// 46 | /// Increasing ordinates values go South. This is rarely used. 47 | /// 48 | South = 2, 49 | /// 50 | /// Increasing ordinates values go East. This is rarely used. 51 | /// 52 | East = 3, 53 | /// 54 | /// Increasing ordinates values go West. This is usually used for Grid X coordinates and Longitude. 55 | /// 56 | West = 4, 57 | /// 58 | /// Increasing ordinates values go up. This is used for vertical coordinate systems. 59 | /// 60 | Up = 5, 61 | /// 62 | /// Increasing ordinates values go down. This is used for vertical coordinate systems. 63 | /// 64 | Down = 6 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/CoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Globalization; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Base interface for all coordinate systems. 31 | /// 32 | /// 33 | /// A coordinate system is a mathematical space, where the elements of the space 34 | /// are called positions. Each position is described by a list of numbers. The length 35 | /// of the list corresponds to the dimension of the coordinate system. So in a 2D 36 | /// coordinate system each position is described by a list containing 2 numbers. 37 | /// However, in a coordinate system, not all lists of numbers correspond to a 38 | /// position - some lists may be outside the domain of the coordinate system. For 39 | /// example, in a 2D Lat/Lon coordinate system, the list (91,91) does not correspond 40 | /// to a position. 41 | /// Some coordinate systems also have a mapping from the mathematical space into 42 | /// locations in the real world. So in a Lat/Lon coordinate system, the mathematical 43 | /// position (lat, long) corresponds to a location on the surface of the Earth. This 44 | /// mapping from the mathematical space into real-world locations is called a Datum. 45 | /// 46 | public abstract class CoordinateSystem : Info, ICoordinateSystem 47 | { 48 | /// 49 | /// Initializes a new instance of a coordinate system. 50 | /// 51 | /// Name 52 | /// Authority name 53 | /// Authority-specific identification code. 54 | /// Alias 55 | /// Abbreviation 56 | /// Provider-supplied remarks 57 | /// axis info 58 | internal CoordinateSystem(string name, string authority, long authorityCode, string alias, string abbreviation, string remarks, List axisInfo) 59 | : base(name, authority, authorityCode, alias, abbreviation, remarks) 60 | { 61 | _AxisInfo = axisInfo; 62 | } 63 | 64 | #region ICoordinateSystem Members 65 | 66 | /// 67 | /// Dimension of the coordinate system. 68 | /// 69 | public int Dimension 70 | { 71 | get { return _AxisInfo.Count; } 72 | } 73 | 74 | /// 75 | /// Gets the units for the dimension within coordinate system. 76 | /// Each dimension in the coordinate system has corresponding units. 77 | /// 78 | public abstract IUnit GetUnits(int dimension); 79 | 80 | private List _AxisInfo; 81 | 82 | internal List AxisInfo 83 | { 84 | get { return _AxisInfo; } 85 | } 86 | 87 | 88 | /// 89 | /// Gets axis details for dimension within coordinate system. 90 | /// 91 | /// Dimension 92 | /// Axis info 93 | public AxisInfo GetAxis(int dimension) 94 | { 95 | if (dimension >= _AxisInfo.Count || dimension < 0) 96 | throw new ArgumentException("AxisInfo not available for dimension " + dimension.ToString(CultureInfo.InvariantCulture)); 97 | return _AxisInfo[dimension]; 98 | } 99 | 100 | /// 101 | /// Gets default envelope of coordinate system. 102 | /// 103 | /// 104 | /// Coordinate systems which are bounded should return the minimum bounding box of their domain. 105 | /// Unbounded coordinate systems should return a box which is as large as is likely to be used. 106 | /// For example, a (lon,lat) geographic coordinate system in degrees should return a box from 107 | /// (-180,-90) to (180,90), and a geocentric coordinate system could return a box from (-r,-r,-r) 108 | /// to (+r,+r,+r) where r is the approximate radius of the Earth. 109 | /// 110 | public double[] DefaultEnvelope => throw new NotImplementedException(); 111 | 112 | #endregion 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Datum.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | namespace ProjNet.CoordinateSystems 24 | { 25 | /// 26 | /// A set of quantities from which other quantities are calculated. 27 | /// 28 | /// 29 | /// For the OGC abstract model, it can be defined as a set of real points on the earth 30 | /// that have coordinates. EG. A datum can be thought of as a set of parameters 31 | /// defining completely the origin and orientation of a coordinate system with respect 32 | /// to the earth. A textual description and/or a set of parameters describing the 33 | /// relationship of a coordinate system to some predefined physical locations (such 34 | /// as center of mass) and physical directions (such as axis of spin). The definition 35 | /// of the datum may also include the temporal behavior (such as the rate of change of 36 | /// the orientation of the coordinate axes). 37 | /// 38 | public abstract class Datum : Info, IDatum 39 | { 40 | /// 41 | /// Initializes a new instance of a Datum object 42 | /// 43 | /// Datum type 44 | /// Name 45 | /// Authority name 46 | /// Authority-specific identification code. 47 | /// Alias 48 | /// Abbreviation 49 | /// Provider-supplied remarks 50 | internal Datum(DatumType type, 51 | string name, string authority, long code, string alias, 52 | string remarks, string abbreviation) 53 | : base(name, authority, code, alias, abbreviation, remarks) 54 | { 55 | _DatumType = type; 56 | } 57 | #region IDatum Members 58 | 59 | private DatumType _DatumType; 60 | 61 | /// 62 | /// Gets or sets the type of the datum as an enumerated code. 63 | /// 64 | public DatumType DatumType 65 | { 66 | get { return _DatumType; } 67 | set { _DatumType = value; } 68 | } 69 | 70 | #endregion 71 | 72 | /// 73 | /// Checks whether the values of this instance is equal to the values of another instance. 74 | /// Only parameters used for coordinate system are used for comparison. 75 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 76 | /// 77 | /// 78 | /// True if equal 79 | public override bool EqualParams(object obj) 80 | { 81 | if (!(obj is Datum d)) 82 | return false; 83 | return d.DatumType == this.DatumType; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/DatumType.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A vertical datum of geoid model derived heights, also called GPS-derived heights. 31 | /// These heights are approximations of orthometric heights (H), constructed from the 32 | /// ellipsoidal heights (h) by the use of the given geoid undulation model (N) through 33 | /// the equation: H=h-N. 34 | /// 35 | public enum DatumType : int 36 | { 37 | /// 38 | /// Lowest possible value for horizontal datum types 39 | /// 40 | HD_Min = 1000, 41 | /// 42 | /// Unspecified horizontal datum type. Horizontal datums with this type should never 43 | /// supply a conversion to WGS84 using Bursa Wolf parameters. 44 | /// 45 | HD_Other = 1000, 46 | /// 47 | /// These datums, such as ED50, NAD27 and NAD83, have been designed to support 48 | /// horizontal positions on the ellipsoid as opposed to positions in 3-D space. These datums were designed mainly to support a horizontal component of a position in a domain of limited extent, such as a country, a region or a continent. 49 | /// 50 | HD_Classic = 1001, 51 | /// 52 | /// A geocentric datum is a "satellite age" modern geodetic datum mainly of global 53 | /// extent, such as WGS84 (used in GPS), PZ90 (used in GLONASS) and ITRF. These 54 | /// datums were designed to support both a horizontal component of position and 55 | /// a vertical component of position (through ellipsoidal heights). The regional 56 | /// realizations of ITRF, such as ETRF, are also included in this category. 57 | /// 58 | HD_Geocentric = 1002, 59 | /// 60 | /// Highest possible value for horizontal datum types. 61 | /// 62 | HD_Max = 1999, 63 | /// 64 | /// Lowest possible value for vertical datum types. 65 | /// 66 | VD_Min = 2000, 67 | /// 68 | /// Unspecified vertical datum type. 69 | /// 70 | VD_Other = 2000, 71 | /// 72 | /// A vertical datum for orthometric heights that are measured along the plumb line. 73 | /// 74 | VD_Orthometric = 2001, 75 | /// 76 | /// A vertical datum for ellipsoidal heights that are measured along the normal to 77 | /// the ellipsoid used in the definition of horizontal datum. 78 | /// 79 | VD_Ellipsoidal = 2002, 80 | /// 81 | /// The vertical datum of altitudes or heights in the atmosphere. These are 82 | /// approximations of orthometric heights obtained with the help of a barometer or 83 | /// a barometric altimeter. These values are usually expressed in one of the 84 | /// following units: meters, feet, millibars (used to measure pressure levels), or 85 | /// theta value (units used to measure geopotential height). 86 | /// 87 | VD_AltitudeBarometric = 2003, 88 | /// 89 | /// A normal height system. 90 | /// 91 | VD_Normal = 2004, 92 | /// 93 | /// A vertical datum of geoid model derived heights, also called GPS-derived heights. 94 | /// These heights are approximations of orthometric heights (H), constructed from the 95 | /// ellipsoidal heights (h) by the use of the given geoid undulation model (N) 96 | /// through the equation: H=h-N. 97 | /// 98 | VD_GeoidModelDerived = 2005, 99 | /// 100 | /// This attribute is used to support the set of datums generated for hydrographic 101 | /// engineering projects where depth measurements below sea level are needed. It is 102 | /// often called a hydrographic or a marine datum. Depths are measured in the 103 | /// direction perpendicular (approximately) to the actual equipotential surfaces of 104 | /// the earth's gravity field, using such procedures as echo-sounding. 105 | /// 106 | VD_Depth = 2006, 107 | /// 108 | /// Highest possible value for vertical datum types. 109 | /// 110 | VD_Max = 2999, 111 | /// 112 | /// Lowest possible value for local datum types. 113 | /// 114 | LD_Min = 10000, 115 | /// 116 | /// Highest possible value for local datum types. 117 | /// 118 | LD_Max = 32767 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Ellipsoid.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/Ellipsoid.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/GeocentricCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Globalization; 26 | using System.Text; 27 | 28 | namespace ProjNet.CoordinateSystems 29 | { 30 | /// 31 | /// A 3D coordinate system, with its origin at the center of the Earth. 32 | /// 33 | public class GeocentricCoordinateSystem : CoordinateSystem, IGeocentricCoordinateSystem 34 | { 35 | internal GeocentricCoordinateSystem(IHorizontalDatum datum, ILinearUnit linearUnit, IPrimeMeridian primeMeridian, List axisinfo, 36 | string name, string authority, long code, string alias, 37 | string remarks, string abbreviation) 38 | : base(name, authority, code, alias, abbreviation, remarks, axisinfo) 39 | { 40 | _HorizontalDatum = datum; 41 | _LinearUnit = linearUnit; 42 | _Primemeridan = primeMeridian; 43 | if (axisinfo.Count != 3) 44 | throw new ArgumentException("Axis info should contain three axes for geocentric coordinate systems"); 45 | } 46 | 47 | #region Predefined geographic coordinate systems 48 | 49 | /// 50 | /// Creates a geocentric coordinate system based on the WGS84 ellipsoid, suitable for GPS measurements 51 | /// 52 | public static IGeocentricCoordinateSystem WGS84 53 | { 54 | get 55 | { 56 | return new CoordinateSystemFactory().CreateGeocentricCoordinateSystem("WGS84 Geocentric", 57 | CoordinateSystems.HorizontalDatum.WGS84, CoordinateSystems.LinearUnit.Metre, 58 | CoordinateSystems.PrimeMeridian.Greenwich); 59 | } 60 | } 61 | 62 | #endregion 63 | 64 | #region IGeocentricCoordinateSystem Members 65 | 66 | private IHorizontalDatum _HorizontalDatum; 67 | 68 | /// 69 | /// Returns the HorizontalDatum. The horizontal datum is used to determine where 70 | /// the centre of the Earth is considered to be. All coordinate points will be 71 | /// measured from the centre of the Earth, and not the surface. 72 | /// 73 | public IHorizontalDatum HorizontalDatum 74 | { 75 | get { return _HorizontalDatum; } 76 | set { _HorizontalDatum = value; } 77 | } 78 | 79 | private ILinearUnit _LinearUnit; 80 | 81 | /// 82 | /// Gets the units used along all the axes. 83 | /// 84 | public ILinearUnit LinearUnit 85 | { 86 | get { return _LinearUnit; } 87 | set { _LinearUnit = value; } 88 | } 89 | 90 | /// 91 | /// Gets units for dimension within coordinate system. Each dimension in 92 | /// the coordinate system has corresponding units. 93 | /// 94 | /// Dimension 95 | /// Unit 96 | public override IUnit GetUnits(int dimension) 97 | { 98 | return _LinearUnit; 99 | } 100 | 101 | private IPrimeMeridian _Primemeridan; 102 | 103 | /// 104 | /// Returns the PrimeMeridian. 105 | /// 106 | public IPrimeMeridian PrimeMeridian 107 | { 108 | get { return _Primemeridan; } 109 | set { _Primemeridan = value; } 110 | } 111 | 112 | /// 113 | /// Returns the Well-known text for this object 114 | /// as defined in the simple features specification. 115 | /// 116 | public override string WKT 117 | { 118 | get 119 | { 120 | StringBuilder sb = new StringBuilder(); 121 | sb.AppendFormat("GEOCCS[\"{0}\", {1}, {2}, {3}", Name, HorizontalDatum.WKT, PrimeMeridian.WKT, LinearUnit.WKT); 122 | //Skip axis info if they contain default values 123 | if (AxisInfo.Count != 3 || 124 | AxisInfo[0].Name != "X" || AxisInfo[0].Orientation != AxisOrientationEnum.Other || 125 | AxisInfo[1].Name != "Y" || AxisInfo[1].Orientation != AxisOrientationEnum.East || 126 | AxisInfo[2].Name != "Z" || AxisInfo[2].Orientation != AxisOrientationEnum.North) 127 | for (int i = 0; i < AxisInfo.Count; i++) 128 | sb.AppendFormat(", {0}", GetAxis(i).WKT); 129 | if (!String.IsNullOrEmpty(Authority) && AuthorityCode>0) 130 | sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); 131 | sb.Append("]"); 132 | return sb.ToString(); 133 | } 134 | } 135 | 136 | /// 137 | /// Gets an XML representation of this object 138 | /// 139 | public override string XML 140 | { 141 | get 142 | { 143 | StringBuilder sb = new StringBuilder(); 144 | sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, 145 | "{1}", 146 | this.Dimension, InfoXml); 147 | foreach (AxisInfo ai in this.AxisInfo) 148 | sb.Append(ai.XML); 149 | sb.AppendFormat("{0}{1}{2}", 150 | HorizontalDatum.XML, LinearUnit.XML, PrimeMeridian.XML); 151 | return sb.ToString(); 152 | } 153 | } 154 | 155 | /// 156 | /// Checks whether the values of this instance is equal to the values of another instance. 157 | /// Only parameters used for coordinate system are used for comparison. 158 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 159 | /// 160 | /// 161 | /// True if equal 162 | public override bool EqualParams(object obj) 163 | { 164 | if (!(obj is GeocentricCoordinateSystem gcc)) 165 | return false; 166 | return gcc.HorizontalDatum.EqualParams(this.HorizontalDatum) && 167 | gcc.LinearUnit.EqualParams(this.LinearUnit) && 168 | gcc.PrimeMeridian.EqualParams(this.PrimeMeridian); 169 | } 170 | 171 | #endregion 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/GeographicCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Globalization; 26 | using System.Text; 27 | 28 | namespace ProjNet.CoordinateSystems 29 | { 30 | /// 31 | /// A coordinate system based on latitude and longitude. 32 | /// 33 | /// 34 | /// Some geographic coordinate systems are Lat/Lon, and some are Lon/Lat. 35 | /// You can find out which this is by examining the axes. You should also 36 | /// check the angular units, since not all geographic coordinate systems 37 | /// use degrees. 38 | /// 39 | public class GeographicCoordinateSystem : HorizontalCoordinateSystem, IGeographicCoordinateSystem 40 | { 41 | 42 | /// 43 | /// Creates an instance of a Geographic Coordinate System 44 | /// 45 | /// Angular units 46 | /// Horizontal datum 47 | /// Prime meridian 48 | /// Axis info 49 | /// Name 50 | /// Authority name 51 | /// Authority-specific identification code. 52 | /// Alias 53 | /// Abbreviation 54 | /// Provider-supplied remarks 55 | internal GeographicCoordinateSystem(IAngularUnit angularUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian, List axisInfo, string name, string authority, long authorityCode, string alias, string abbreviation, string remarks) 56 | : 57 | base(horizontalDatum, axisInfo, name, authority, authorityCode, alias, abbreviation, remarks) 58 | { 59 | _AngularUnit = angularUnit; 60 | _PrimeMeridian = primeMeridian; 61 | } 62 | 63 | #region Predefined geographic coordinate systems 64 | 65 | /// 66 | /// Creates a decimal degrees geographic coordinate system based on the WGS84 ellipsoid, suitable for GPS measurements 67 | /// 68 | public static GeographicCoordinateSystem WGS84 69 | { 70 | get { 71 | List axes = new List(2); 72 | axes.Add(new AxisInfo("Lon", AxisOrientationEnum.East)); 73 | axes.Add(new AxisInfo("Lat", AxisOrientationEnum.North)); 74 | return new GeographicCoordinateSystem(CoordinateSystems.AngularUnit.Degrees, 75 | CoordinateSystems.HorizontalDatum.WGS84, CoordinateSystems.PrimeMeridian.Greenwich, axes, 76 | "WGS 84", "EPSG", 4326, String.Empty, string.Empty, string.Empty); 77 | } 78 | } 79 | 80 | #endregion 81 | 82 | #region IGeographicCoordinateSystem Members 83 | 84 | private IAngularUnit _AngularUnit; 85 | 86 | /// 87 | /// Gets or sets the angular units of the geographic coordinate system. 88 | /// 89 | public IAngularUnit AngularUnit 90 | { 91 | get { return _AngularUnit; } 92 | set { _AngularUnit = value; } 93 | } 94 | 95 | /// 96 | /// Gets units for dimension within coordinate system. Each dimension in 97 | /// the coordinate system has corresponding units. 98 | /// 99 | /// Dimension 100 | /// Unit 101 | public override IUnit GetUnits(int dimension) 102 | { 103 | return _AngularUnit; 104 | } 105 | private IPrimeMeridian _PrimeMeridian; 106 | 107 | /// 108 | /// Gets or sets the prime meridian of the geographic coordinate system. 109 | /// 110 | public IPrimeMeridian PrimeMeridian 111 | { 112 | get { return _PrimeMeridian; } 113 | set { _PrimeMeridian = value; } 114 | } 115 | 116 | /// 117 | /// Gets the number of available conversions to WGS84 coordinates. 118 | /// 119 | public int NumConversionToWGS84 120 | { 121 | get { return _WGS84ConversionInfo?.Count ?? 0; } 122 | } 123 | 124 | private List? _WGS84ConversionInfo; 125 | 126 | internal List? WGS84ConversionInfo 127 | { 128 | get { return _WGS84ConversionInfo; } 129 | set { _WGS84ConversionInfo = value; } 130 | } 131 | 132 | /// 133 | /// Gets details on a conversion to WGS84. 134 | /// 135 | public Wgs84ConversionInfo GetWgs84ConversionInfo(int index) 136 | { 137 | if (_WGS84ConversionInfo == null) 138 | throw new ArgumentOutOfRangeException(nameof(index)); 139 | return _WGS84ConversionInfo[index]; 140 | } 141 | 142 | /// 143 | /// Returns the Well-known text for this object 144 | /// as defined in the simple features specification. 145 | /// 146 | public override string WKT 147 | { 148 | get 149 | { 150 | StringBuilder sb = new StringBuilder(); 151 | sb.AppendFormat("GEOGCS[\"{0}\", {1}, {2}, {3}",Name, HorizontalDatum.WKT, PrimeMeridian.WKT, AngularUnit.WKT); 152 | //Skip axis info if they contain default values 153 | if (AxisInfo.Count != 2 || 154 | AxisInfo[0].Name != "Lon" || AxisInfo[0].Orientation != AxisOrientationEnum.East || 155 | AxisInfo[1].Name != "Lat" || AxisInfo[1].Orientation != AxisOrientationEnum.North) 156 | for (int i = 0; i < AxisInfo.Count; i++) 157 | sb.AppendFormat(", {0}", GetAxis(i).WKT); 158 | if (!String.IsNullOrEmpty(Authority) && AuthorityCode > 0) 159 | sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); 160 | sb.Append("]"); 161 | return sb.ToString(); 162 | } 163 | } 164 | 165 | /// 166 | /// Gets an XML representation of this object 167 | /// 168 | public override string XML 169 | { 170 | get 171 | { 172 | StringBuilder sb = new StringBuilder(); 173 | sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, 174 | "{1}", 175 | this.Dimension, InfoXml); 176 | foreach(AxisInfo ai in this.AxisInfo) 177 | sb.Append(ai.XML); 178 | sb.AppendFormat("{0}{1}{2}", 179 | HorizontalDatum.XML, AngularUnit.XML, PrimeMeridian.XML); 180 | return sb.ToString(); 181 | } 182 | } 183 | 184 | /// 185 | /// Checks whether the values of this instance is equal to the values of another instance. 186 | /// Only parameters used for coordinate system are used for comparison. 187 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 188 | /// 189 | /// 190 | /// True if equal 191 | public override bool EqualParams(object obj) 192 | { 193 | if (!(obj is GeographicCoordinateSystem gcs)) 194 | return false; 195 | if (gcs.Dimension != this.Dimension) return false; 196 | if (this.WGS84ConversionInfo != null && gcs.WGS84ConversionInfo == null) return false; 197 | if (this.WGS84ConversionInfo == null && gcs.WGS84ConversionInfo != null) return false; 198 | if (this.WGS84ConversionInfo != null && gcs.WGS84ConversionInfo != null) 199 | { 200 | if (this.WGS84ConversionInfo.Count != gcs.WGS84ConversionInfo.Count) return false; 201 | for (int i = 0; i < this.WGS84ConversionInfo.Count; i++) 202 | if (!gcs.WGS84ConversionInfo[i].Equals(this.WGS84ConversionInfo[i])) 203 | return false; 204 | } 205 | if (this.AxisInfo.Count != gcs.AxisInfo.Count) return false; 206 | for (int i = 0; i < gcs.AxisInfo.Count; i++) 207 | if (gcs.AxisInfo[i].Orientation != this.AxisInfo[i].Orientation) 208 | return false; 209 | return gcs.AngularUnit.EqualParams(this.AngularUnit) && 210 | gcs.HorizontalDatum.EqualParams(this.HorizontalDatum) && 211 | gcs.PrimeMeridian.EqualParams(this.PrimeMeridian); 212 | } 213 | #endregion 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/GeographicTransform.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | 26 | namespace ProjNet.CoordinateSystems 27 | { 28 | /// 29 | /// The GeographicTransform class is implemented on geographic transformation objects and 30 | /// implements datum transformations between geographic coordinate systems. 31 | /// 32 | public class GeographicTransform : Info, IGeographicTransform 33 | { 34 | internal GeographicTransform( 35 | string name, string authority, long code, string alias, string remarks, string abbreviation, 36 | IGeographicCoordinateSystem sourceGCS, IGeographicCoordinateSystem targetGCS) 37 | : base(name, authority, code, alias, abbreviation, remarks) 38 | { 39 | _SourceGCS = sourceGCS; 40 | _TargetGCS = targetGCS; 41 | } 42 | 43 | #region IGeographicTransform Members 44 | 45 | private IGeographicCoordinateSystem _SourceGCS; 46 | 47 | /// 48 | /// Gets or sets the source geographic coordinate system for the transformation. 49 | /// 50 | public IGeographicCoordinateSystem SourceGCS 51 | { 52 | get { return _SourceGCS; } 53 | set { _SourceGCS = value; } 54 | } 55 | 56 | private IGeographicCoordinateSystem _TargetGCS; 57 | 58 | /// 59 | /// Gets or sets the target geographic coordinate system for the transformation. 60 | /// 61 | public IGeographicCoordinateSystem TargetGCS 62 | { 63 | get { return _TargetGCS; } 64 | set { _TargetGCS = value; } 65 | } 66 | 67 | /// 68 | /// Returns an accessor interface to the parameters for this geographic transformation. 69 | /// 70 | public IParameterInfo ParameterInfo 71 | { 72 | get { throw new NotImplementedException(); } 73 | } 74 | 75 | /// 76 | /// Transforms an array of points from the source geographic coordinate 77 | /// system to the target geographic coordinate system. 78 | /// 79 | /// On input points in the source geographic coordinate system 80 | /// Output points in the target geographic coordinate system 81 | public List Forward(List points) 82 | { 83 | throw new NotImplementedException(); 84 | /* 85 | List trans = new List(points.Count); 86 | foreach (Point p in points) 87 | { 88 | 89 | } 90 | return trans; 91 | */ 92 | } 93 | 94 | /// 95 | /// Transforms an array of points from the target geographic coordinate 96 | /// system to the source geographic coordinate system. 97 | /// 98 | /// Input points in the target geographic coordinate system, 99 | /// Output points in the source geographic coordinate system 100 | public List Inverse(List points) 101 | { 102 | throw new NotImplementedException(); 103 | } 104 | 105 | /// 106 | /// Returns the Well-known text for this object 107 | /// as defined in the simple features specification. 108 | /// 109 | public override string WKT 110 | { 111 | get 112 | { 113 | throw new NotImplementedException(); 114 | } 115 | } 116 | 117 | /// 118 | /// Gets an XML representation of this object [NOT IMPLEMENTED]. 119 | /// 120 | public override string XML 121 | { 122 | get 123 | { 124 | throw new NotImplementedException(); 125 | } 126 | } 127 | 128 | /// 129 | /// Checks whether the values of this instance is equal to the values of another instance. 130 | /// Only parameters used for coordinate system are used for comparison. 131 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 132 | /// 133 | /// 134 | /// True if equal 135 | public override bool EqualParams(object obj) 136 | { 137 | if (!(obj is GeographicTransform gt)) 138 | return false; 139 | return gt.SourceGCS.EqualParams(this.SourceGCS) && gt.TargetGCS.EqualParams(this.TargetGCS); 140 | } 141 | #endregion 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/HorizontalCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | 26 | namespace ProjNet.CoordinateSystems 27 | { 28 | /// 29 | /// A 2D coordinate system suitable for positions on the Earth's surface. 30 | /// 31 | public abstract class HorizontalCoordinateSystem : CoordinateSystem, IHorizontalCoordinateSystem 32 | { 33 | /// 34 | /// Creates an instance of HorizontalCoordinateSystem 35 | /// 36 | /// Horizontal datum 37 | /// Axis information 38 | /// Name 39 | /// Authority name 40 | /// Authority-specific identification code. 41 | /// Alias 42 | /// Abbreviation 43 | /// Provider-supplied remarks 44 | internal HorizontalCoordinateSystem(IHorizontalDatum datum, List axisInfo, 45 | string name, string authority, long code, string alias, 46 | string remarks, string abbreviation) 47 | : base(name, authority, code, alias, abbreviation, remarks, axisInfo) 48 | { 49 | _HorizontalDatum = datum; 50 | if (axisInfo.Count != 2) 51 | throw new ArgumentException("Axis info should contain two axes for horizontal coordinate systems"); 52 | } 53 | 54 | #region IHorizontalCoordinateSystem Members 55 | 56 | private IHorizontalDatum _HorizontalDatum; 57 | 58 | /// 59 | /// Gets or sets the HorizontalDatum. 60 | /// 61 | public IHorizontalDatum HorizontalDatum 62 | { 63 | get { return _HorizontalDatum; } 64 | set { _HorizontalDatum = value; } 65 | } 66 | 67 | #endregion 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IAngularUnit.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IAngularUnit interface defines methods on angular units. 31 | /// 32 | public interface IAngularUnit : IUnit 33 | { 34 | /// 35 | /// Gets or sets the number of radians per angular unit. 36 | /// 37 | double RadiansPerUnit { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/ICompoundCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// An aggregate of two coordinate systems (CRS). One of these is usually a 31 | /// CRS based on a two dimensional coordinate system such as a geographic or 32 | /// a projected coordinate system with a horizontal datum. The other is a 33 | /// vertical CRS which is a one-dimensional coordinate system with a vertical 34 | /// datum. 35 | /// 36 | public interface ICompoundCoordinateSystem : ICoordinateSystem 37 | { 38 | /// 39 | /// Gets first sub-coordinate system. 40 | /// 41 | CoordinateSystem HeadCS { get; } 42 | /// 43 | /// Gets second sub-coordinate system. 44 | /// 45 | CoordinateSystem TailCS { get; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/ICoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Base interface for all coordinate systems 31 | /// 32 | /// 33 | /// A coordinate system is a mathematical space, where the elements of the space are called 34 | /// positions. Each position is described by a list of numbers. The length of the list corresponds 35 | /// to the dimension of the coordinate system. So in a 2D coordinate system each position is 36 | /// described by a list containing 2 numbers. 37 | /// 38 | /// However, in a coordinate system, not all lists of numbers correspond to a position - 39 | /// some lists may be outside the domain of the coordinate system. For example, in a 2D Lat/Lon 40 | /// coordinate system, the list (91,91) does not correspond to a position. 41 | /// 42 | /// Some coordinate systems also have a mapping from the mathematical space into locations 43 | /// in the real world. So in a Lat/Lon coordinate system, the mathematical position (lat, long) 44 | /// corresponds to a location on the surface of the Earth. This mapping from the mathematical 45 | /// space into real-world locations is called a Datum. 46 | /// 47 | public interface ICoordinateSystem : IInfo 48 | { 49 | 50 | /// 51 | /// Dimension of the coordinate system. 52 | /// 53 | int Dimension { get; } 54 | 55 | /// 56 | /// Gets axis details for dimension within coordinate system. 57 | /// 58 | /// Dimension 59 | /// Axis info 60 | AxisInfo GetAxis(int dimension); 61 | 62 | /// 63 | /// Gets units for dimension within coordinate system. 64 | /// 65 | IUnit GetUnits(int dimension); 66 | 67 | /// 68 | /// Gets default envelope of coordinate system. 69 | /// 70 | /// 71 | /// Gets default envelope of coordinate system. Coordinate systems 72 | /// which are bounded should return the minimum bounding box of their 73 | /// domain. Unbounded coordinate systems should return a box which is 74 | /// as large as is likely to be used. For example, a (lon,lat) 75 | /// geographic coordinate system in degrees should return a box from 76 | /// (-180,-90) to (180,90), and a geocentric coordinate system could 77 | /// return a box from (-r,-r,-r) to (+r,+r,+r) where r is the 78 | /// approximate radius of the Earth. 79 | /// 80 | double[] DefaultEnvelope { get; } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IDatum.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A set of quantities from which other quantities are calculated. 31 | /// 32 | /// 33 | /// For the OGC abstract model, it can be defined as a set of real points on the earth 34 | /// that have coordinates. EG. A datum can be thought of as a set of parameters 35 | /// defining completely the origin and orientation of a coordinate system with respect 36 | /// to the earth. A textual description and/or a set of parameters describing the 37 | /// relationship of a coordinate system to some predefined physical locations (such 38 | /// as center of mass) and physical directions (such as axis of spin). The definition 39 | /// of the datum may also include the temporal behavior (such as the rate of change of 40 | /// the orientation of the coordinate axes). 41 | /// 42 | public interface IDatum : IInfo 43 | { 44 | /// 45 | /// Gets or sets the type of the datum as an enumerated code. 46 | /// 47 | DatumType DatumType { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IEllipsoid.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IEllipsoid interface defines the standard information stored with ellipsoid objects. 31 | /// 32 | public interface IEllipsoid : IInfo 33 | { 34 | /// 35 | /// Gets or sets the value of the semi-major axis. 36 | /// 37 | double SemiMajorAxis { get; set; } 38 | /// 39 | /// Gets or sets the value of the semi-minor axis. 40 | /// 41 | double SemiMinorAxis { get; set; } 42 | /// 43 | /// Gets or sets the value of the inverse of the flattening constant of the ellipsoid. 44 | /// 45 | double InverseFlattening { get; set; } 46 | /// 47 | /// Gets or sets the value of the axis unit. 48 | /// 49 | ILinearUnit AxisUnit { get; set; } 50 | /// 51 | /// Is the Inverse Flattening definitive for this ellipsoid? Some ellipsoids use the 52 | /// IVF as the defining value, and calculate the polar radius whenever asked. Other 53 | /// ellipsoids use the polar radius to calculate the IVF whenever asked. This 54 | /// distinction can be important to avoid floating-point rounding errors. 55 | /// 56 | bool IsIvfDefinitive { get; set; } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IFittedCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A coordinate system which sits inside another coordinate system. The fitted 31 | /// coordinate system can be rotated and shifted, or use any other math transform 32 | /// to inject itself into the base coordinate system. 33 | /// 34 | public interface IFittedCoordinateSystem : ICoordinateSystem 35 | { 36 | /// 37 | /// Gets underlying coordinate system. 38 | /// 39 | ICoordinateSystem BaseCoordinateSystem { get; } 40 | /// 41 | /// Gets Well-Known Text of a math transform to the base coordinate system. 42 | /// The dimension of this fitted coordinate system is determined by the source 43 | /// dimension of the math transform. The transform should be one-to-one within 44 | /// this coordinate system's domain, and the base coordinate system dimension 45 | /// must be at least as big as the dimension of this coordinate system. 46 | /// 47 | /// 48 | string ToBase(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IGeocentricCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A 3D coordinate system, with its origin at the center of the Earth. 31 | /// 32 | public interface IGeocentricCoordinateSystem : ICoordinateSystem 33 | { 34 | /// 35 | /// Returns the HorizontalDatum. The horizontal datum is used to determine where 36 | /// the centre of the Earth is considered to be. All coordinate points will be 37 | /// measured from the centre of the Earth, and not the surface. 38 | /// 39 | IHorizontalDatum HorizontalDatum { get; set; } 40 | /// 41 | /// Gets the units used along all the axes. 42 | /// 43 | ILinearUnit LinearUnit { get; set; } 44 | /// 45 | /// Returns the PrimeMeridian. 46 | /// 47 | IPrimeMeridian PrimeMeridian { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IGeodeticSpatialReference.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IGeodeticSpatialReference interface defines a root interface for all types of geodetic 31 | /// spatial references, it is a subclass of ICoordinateSystem. 32 | /// 33 | public interface IGeodeticSpatialReference : ICoordinateSystem { } 34 | } 35 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IGeographicCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IGeographicCoordinateSystem interface is a subclass of IGeodeticSpatialReference and 31 | /// defines the standard information stored with geographic coordinate system objects. 32 | /// 33 | public interface IGeographicCoordinateSystem : IHorizontalCoordinateSystem 34 | { 35 | /// 36 | /// Gets or sets the angular units of the geographic coordinate system. 37 | /// 38 | IAngularUnit AngularUnit { get; set; } 39 | /// 40 | /// Gets or sets the prime meridian of the geographic coordinate system. 41 | /// 42 | IPrimeMeridian PrimeMeridian { get; set; } 43 | /// 44 | /// Gets the number of available conversions to WGS84 coordinates. 45 | /// 46 | int NumConversionToWGS84 { get; } 47 | /// 48 | /// Gets details on a conversion to WGS84. 49 | /// 50 | Wgs84ConversionInfo GetWgs84ConversionInfo(int index); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IGeographicTransform.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IGeographicTransform interface is implemented on geographic transformation 31 | /// objects and implements datum transformations between geographic coordinate systems. 32 | /// 33 | public interface IGeographicTransform : IInfo 34 | { 35 | /// 36 | /// Gets or sets source geographic coordinate system for the transformation. 37 | /// 38 | IGeographicCoordinateSystem SourceGCS { get; set; } 39 | 40 | /// 41 | /// Gets or sets the target geographic coordinate system for the transformation. 42 | /// 43 | IGeographicCoordinateSystem TargetGCS { get; set; } 44 | 45 | /// 46 | /// Returns an accessor interface to the parameters for this geographic transformation. 47 | /// 48 | IParameterInfo ParameterInfo { get; } 49 | 50 | /// 51 | /// Transforms an array of points from the source geographic coordinate system 52 | /// to the target geographic coordinate system. 53 | /// 54 | /// Points in the source geographic coordinate system 55 | /// Points in the target geographic coordinate system 56 | List Forward(List points); 57 | 58 | /// 59 | /// Transforms an array of points from the target geographic coordinate system 60 | /// to the source geographic coordinate system. 61 | /// 62 | /// Points in the target geographic coordinate system 63 | /// Points in the source geographic coordinate system 64 | List Inverse(List points); 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IHorizontalCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A 2D coordinate system suitable for positions on the Earth's surface. 31 | /// 32 | public interface IHorizontalCoordinateSystem : ICoordinateSystem 33 | { 34 | /// 35 | /// Returns the HorizontalDatum. 36 | /// 37 | IHorizontalDatum HorizontalDatum { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IHorizontalDatum.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Procedure used to measure positions on the surface of the Earth. 31 | /// 32 | public interface IHorizontalDatum : IDatum 33 | { 34 | /// 35 | /// Gets or sets the ellipsoid of the datum. 36 | /// 37 | IEllipsoid Ellipsoid { get; set; } 38 | /// 39 | /// Gets preferred parameters for a Bursa Wolf transformation into WGS84. The 7 returned values 40 | /// correspond to (dx,dy,dz) in meters, (ex,ey,ez) in arc-seconds, and scaling in parts-per-million. 41 | /// 42 | Wgs84ConversionInfo? Wgs84Parameters { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/IInfo.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/ILinearUnit.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The ILinearUnit interface defines methods on linear units. 31 | /// 32 | public interface ILinearUnit : IUnit 33 | { 34 | /// 35 | /// Gets or sets the number of meters per . 36 | /// 37 | double MetersPerUnit { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/ILocalCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A local coordinate system, with uncertain relationship to the world. 31 | /// 32 | /// In general, a local coordinate system cannot be related to other coordinate 33 | /// systems. However, if two objects supporting this interface have the same dimension, 34 | /// axes, units and datum then client code is permitted to assume that the two coordinate 35 | /// systems are identical. This allows several datasets from a common source (e.g. a CAD 36 | /// system) to be overlaid. In addition, some implementations of the Coordinate 37 | /// Transformation (CT) package may have a mechanism for correlating local datums. (E.g. 38 | /// from a database of transformations, which is created and maintained from real-world 39 | /// measurements.) 40 | /// 41 | public interface ILocalCoordinateSystem : ICoordinateSystem 42 | { 43 | /// 44 | /// Gets or sets the local datum 45 | /// 46 | ILocalDatum LocalDatum { get; set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/ILocalDatum.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Local datum. If two local datum objects have the same datum type and name, 31 | /// then they can be considered equal. This means that coordinates can be 32 | /// transformed between two different local coordinate systems, as long as 33 | /// they are based on the same local datum. 34 | /// 35 | public interface ILocalDatum : IDatum 36 | { 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IParameterInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IParameterInfo interface provides an interface through which clients of a 31 | /// Projected Coordinate System or of a Projection can set the parameters of the 32 | /// projection. It provides a generic interface for discovering the names and default 33 | /// values of parameters, and for setting and getting parameter values. Subclasses of 34 | /// this interface may provide projection specific parameter access methods. 35 | /// 36 | public interface IParameterInfo 37 | { 38 | /// 39 | /// Gets the number of parameters expected. 40 | /// 41 | int NumParameters { get; } 42 | /// 43 | /// Returns the default parameters for this projection. 44 | /// 45 | /// 46 | Parameter[] DefaultParameters(); 47 | /// 48 | /// Gets or sets the parameters set for this projection. 49 | /// 50 | List Parameters { get; set; } 51 | /// 52 | /// Gets the parameter by its name 53 | /// 54 | /// 55 | /// 56 | Parameter GetParameterByName(string name); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IPrimeMeridian.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IPrimeMeridian interface defines the standard information stored with prime 31 | /// meridian objects. Any prime meridian object must implement this interface as 32 | /// well as the ISpatialReferenceInfo interface. 33 | /// 34 | public interface IPrimeMeridian : IInfo 35 | { 36 | /// 37 | /// Gets or sets the longitude of the prime meridian (relative to the Greenwich prime meridian). 38 | /// 39 | double Longitude { get; set; } 40 | /// 41 | /// Gets or sets the AngularUnits. 42 | /// 43 | IAngularUnit AngularUnit { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IProjectedCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IProjectedCoordinateSystem interface defines the standard information stored with 31 | /// projected coordinate system objects. A projected coordinate system is defined using a 32 | /// geographic coordinate system object and a projection object that defines the 33 | /// coordinate transformation from the geographic coordinate system to the projected 34 | /// coordinate systems. The instances of a single ProjectedCoordinateSystem COM class can 35 | /// be used to model different projected coordinate systems (e.g., UTM Zone 10, Albers) 36 | /// by associating the ProjectedCoordinateSystem instances with Projection instances 37 | /// belonging to different Projection COM classes (Transverse Mercator and Albers, 38 | /// respectively). 39 | /// 40 | public interface IProjectedCoordinateSystem : IHorizontalCoordinateSystem 41 | { 42 | /// 43 | /// Gets or sets the geographic coordinate system associated with the projected 44 | /// coordinate system. 45 | /// 46 | IGeographicCoordinateSystem GeographicCoordinateSystem { get; set; } 47 | /// 48 | /// Gets or sets the linear (projected) units of the projected coordinate system. 49 | /// 50 | ILinearUnit LinearUnit { get; set; } 51 | /// 52 | /// Gets or sets the projection for the projected coordinate system. 53 | /// 54 | IProjection Projection { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IProjection.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IProjection interface defines the standard information stored with projection 31 | /// objects. A projection object implements a coordinate transformation from a geographic 32 | /// coordinate system to a projected coordinate system, given the ellipsoid for the 33 | /// geographic coordinate system. It is expected that each coordinate transformation of 34 | /// interest, e.g., Transverse Mercator, Lambert, will be implemented as a COM class of 35 | /// coType Projection, supporting the IProjection interface. 36 | /// 37 | public interface IProjection : IInfo 38 | { 39 | /// 40 | /// Gets number of parameters of the projection. 41 | /// 42 | int NumParameters { get; } 43 | /// 44 | /// Gets the projection classification name (e.g. 'Transverse_Mercator'). 45 | /// 46 | string ClassName { get; } 47 | /// 48 | /// Gets an indexed parameter of the projection. 49 | /// 50 | /// Index of parameter 51 | /// n'th parameter 52 | ProjectionParameter GetParameter(int n); 53 | 54 | /// 55 | /// Gets an named parameter of the projection. 56 | /// 57 | /// The parameter name is case insensitive 58 | /// Name of parameter 59 | /// parameter or null if not found 60 | ProjectionParameter? GetParameter(string name); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IUnit.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// The IUnit interface abstracts different kinds of units, it has no methods. 31 | /// 32 | public interface IUnit : IInfo { } 33 | } 34 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IVerticalCoordinateSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A one-dimensional coordinate system suitable for vertical measurements. 31 | /// 32 | public interface IVerticalCoordinateSystem : ICoordinateSystem 33 | { 34 | /// 35 | /// Gets the vertical datum, which indicates the measurement method 36 | /// 37 | IVerticalDatum VerticalDatum { get; set; } 38 | /// 39 | /// Gets the units used along the vertical axis. 40 | /// 41 | ILinearUnit VerticalUnit { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/IVerticalDatum.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Procedure used to measure vertical distances. 31 | /// 32 | public interface IVerticalDatum : IDatum 33 | { 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Info.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/Info.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/LinearUnit.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Globalization; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Definition of linear units. 31 | /// 32 | public class LinearUnit : Info, ILinearUnit 33 | { 34 | /// 35 | /// Creates an instance of a linear unit 36 | /// 37 | /// Number of meters per 38 | /// Name 39 | /// Authority name 40 | /// Authority-specific identification code. 41 | /// Alias 42 | /// Abbreviation 43 | /// Provider-supplied remarks 44 | public LinearUnit(double metersPerUnit, string name, string authority, long authorityCode, string alias, string abbreviation, string remarks) 45 | : 46 | base(name, authority, authorityCode, alias, abbreviation, remarks) 47 | { 48 | _MetersPerUnit = metersPerUnit; 49 | } 50 | 51 | #region Predefined units 52 | /// 53 | /// Returns the meters linear unit. 54 | /// Also known as International metre. SI standard unit. 55 | /// 56 | public static ILinearUnit Metre 57 | { 58 | get { return new LinearUnit(1.0,"metre", "EPSG", 9001, "m", String.Empty, "Also known as International metre. SI standard unit."); } 59 | } 60 | /// 61 | /// Returns the foot linear unit (1ft = 0.3048m). 62 | /// 63 | public static ILinearUnit Foot 64 | { 65 | get { return new LinearUnit(0.3048, "foot", "EPSG", 9002, "ft", String.Empty, String.Empty); } 66 | } 67 | /// 68 | /// Returns the US Survey foot linear unit (1ftUS = 0.304800609601219m). 69 | /// 70 | public static ILinearUnit USSurveyFoot 71 | { 72 | get { return new LinearUnit(0.304800609601219, "US survey foot", "EPSG", 9003, "American foot", "ftUS", "Used in USA."); } 73 | } 74 | /// 75 | /// Returns the Nautical Mile linear unit (1NM = 1852m). 76 | /// 77 | public static ILinearUnit NauticalMile 78 | { 79 | get { return new LinearUnit(1852, "nautical mile", "EPSG", 9030, "NM", String.Empty, String.Empty); } 80 | } 81 | 82 | /// 83 | /// Returns Clarke's foot. 84 | /// 85 | /// 86 | /// Assumes Clarke's 1865 ratio of 1 British foot = 0.3047972654 French legal metres applies to the international metre. 87 | /// Used in older Australian, southern African & British West Indian mapping. 88 | /// 89 | public static ILinearUnit ClarkesFoot 90 | { 91 | get { return new LinearUnit(0.3047972654, "Clarke's foot", "EPSG", 9005, "Clarke's foot", String.Empty, "Assumes Clarke's 1865 ratio of 1 British foot = 0.3047972654 French legal metres applies to the international metre. Used in older Australian, southern African & British West Indian mapping."); } 92 | } 93 | #endregion 94 | 95 | #region ILinearUnit Members 96 | 97 | private double _MetersPerUnit; 98 | 99 | /// 100 | /// Gets or sets the number of meters per . 101 | /// 102 | public double MetersPerUnit 103 | { 104 | get { return _MetersPerUnit; } 105 | set { _MetersPerUnit = value; } 106 | } 107 | 108 | /// 109 | /// Returns the Well-known text for this object 110 | /// as defined in the simple features specification. 111 | /// 112 | public override string WKT 113 | { 114 | get 115 | { 116 | StringBuilder sb = new StringBuilder(); 117 | sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "UNIT[\"{0}\", {1}", Name, MetersPerUnit); 118 | if (!String.IsNullOrEmpty(Authority) && AuthorityCode > 0) 119 | sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); 120 | sb.Append("]"); 121 | return sb.ToString(); 122 | } 123 | } 124 | 125 | /// 126 | /// Gets an XML representation of this object 127 | /// 128 | public override string XML 129 | { 130 | get 131 | { 132 | return String.Format(CultureInfo.InvariantCulture.NumberFormat, "{1}", MetersPerUnit, InfoXml); 133 | } 134 | } 135 | 136 | #endregion 137 | 138 | /// 139 | /// Checks whether the values of this instance is equal to the values of another instance. 140 | /// Only parameters used for coordinate system are used for comparison. 141 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 142 | /// 143 | /// 144 | /// True if equal 145 | public override bool EqualParams(object obj) 146 | { 147 | if (!(obj is LinearUnit li)) 148 | return false; 149 | return li.MetersPerUnit == this.MetersPerUnit; 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Parameter.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A named parameter value. 31 | /// 32 | public class Parameter 33 | { 34 | /// 35 | /// Creates an instance of a parameter 36 | /// 37 | /// Units are always either meters or degrees. 38 | /// Name of parameter 39 | /// Value 40 | public Parameter(string name, double value) 41 | { 42 | _Name = name; 43 | _Value = value; 44 | } 45 | #region IParameter Members 46 | 47 | private string _Name; 48 | 49 | /// 50 | /// Parameter name 51 | /// 52 | public string Name 53 | { 54 | get { return _Name; } 55 | set { _Name = value; } 56 | } 57 | 58 | private double _Value; 59 | 60 | /// 61 | /// Parameter value 62 | /// 63 | public double Value 64 | { 65 | get { return _Value; } 66 | set { _Value = value; } 67 | } 68 | 69 | #endregion 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Projection.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Globalization; 26 | using System.Text; 27 | 28 | namespace ProjNet.CoordinateSystems 29 | { 30 | /// 31 | /// The Projection class defines the standard information stored with a projection 32 | /// objects. A projection object implements a coordinate transformation from a geographic 33 | /// coordinate system to a projected coordinate system, given the ellipsoid for the 34 | /// geographic coordinate system. It is expected that each coordinate transformation of 35 | /// interest, e.g., Transverse Mercator, Lambert, will be implemented as a class of 36 | /// type Projection, supporting the IProjection interface. 37 | /// 38 | public class Projection : Info, IProjection 39 | { 40 | internal Projection(string className, List parameters, 41 | string name, string authority, long code, string alias, 42 | string remarks, string abbreviation) 43 | : base(name, authority, code, alias, abbreviation, remarks) 44 | { 45 | _Parameters = parameters; 46 | _ClassName = className; 47 | } 48 | 49 | #region Predefined projections 50 | #endregion 51 | 52 | #region IProjection Members 53 | 54 | /// 55 | /// Gets the number of parameters of the projection. 56 | /// 57 | public int NumParameters 58 | { 59 | get { return _Parameters.Count; } 60 | } 61 | 62 | private List _Parameters; 63 | 64 | /// 65 | /// Gets or sets the parameters of the projection 66 | /// 67 | internal List Parameters 68 | { 69 | get { return _Parameters; } 70 | set { _Parameters = value; } 71 | } 72 | 73 | /// 74 | /// Gets an indexed parameter of the projection. 75 | /// 76 | /// Index of parameter 77 | /// n'th parameter 78 | public ProjectionParameter GetParameter(int n) 79 | { 80 | return _Parameters[n]; 81 | } 82 | 83 | /// 84 | /// Gets a named parameter of the projection. 85 | /// 86 | /// The parameter name is case insensitive 87 | /// Name of parameter 88 | /// parameter or null if not found 89 | public ProjectionParameter? GetParameter(string name) 90 | { 91 | foreach (ProjectionParameter par in _Parameters) 92 | if (par.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) 93 | return par; 94 | return null; 95 | } 96 | 97 | private string _ClassName; 98 | 99 | /// 100 | /// Gets the projection classification name (e.g. "Transverse_Mercator"). 101 | /// 102 | public string ClassName 103 | { 104 | get { return _ClassName; } 105 | } 106 | 107 | /// 108 | /// Returns the Well-known text for this object 109 | /// as defined in the simple features specification. 110 | /// 111 | public override string WKT 112 | { 113 | get 114 | { 115 | StringBuilder sb = new StringBuilder(); 116 | sb.AppendFormat("PROJECTION[\"{0}\"", Name); 117 | if (!String.IsNullOrEmpty(Authority) && AuthorityCode > 0) 118 | sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); 119 | sb.Append("]"); 120 | return sb.ToString(); 121 | } 122 | } 123 | 124 | /// 125 | /// Gets an XML representation of this object 126 | /// 127 | public override string XML 128 | { 129 | get 130 | { 131 | StringBuilder sb = new StringBuilder(); 132 | sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "{1}", ClassName, InfoXml); 133 | foreach (ProjectionParameter param in Parameters) 134 | sb.Append(param.XML); 135 | sb.Append(""); 136 | return sb.ToString(); 137 | } 138 | } 139 | 140 | /// 141 | /// Checks whether the values of this instance is equal to the values of another instance. 142 | /// Only parameters used for coordinate system are used for comparison. 143 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 144 | /// 145 | /// 146 | /// True if equal 147 | public override bool EqualParams(object obj) 148 | { 149 | if (!(obj is Projection proj)) 150 | return false; 151 | if (proj.NumParameters != this.NumParameters) 152 | return false; 153 | for (int i = 0; i < _Parameters.Count; i++) 154 | { 155 | ProjectionParameter? param = GetParameter(proj.GetParameter(i).Name); 156 | if (param == null) 157 | return false; 158 | if (param.Value != proj.GetParameter(i).Value) 159 | return false; 160 | } 161 | return true; 162 | } 163 | 164 | #endregion 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/ProjectionParameter.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// A named projection parameter value. 31 | /// 32 | /// 33 | /// The linear units of parameters' values match the linear units of the containing 34 | /// projected coordinate system. The angular units of parameter values match the 35 | /// angular units of the geographic coordinate system that the projected coordinate 36 | /// system is based on. (Notice that this is different from , 37 | /// where the units are always meters and degrees.) 38 | /// 39 | public class ProjectionParameter 40 | { 41 | /// 42 | /// Initializes an instance of a ProjectionParameter 43 | /// 44 | /// Name of parameter 45 | /// Parameter value 46 | public ProjectionParameter(string name, double value) 47 | { 48 | _Name = name; 49 | _Value = value; 50 | } 51 | 52 | private string _Name; 53 | 54 | /// 55 | /// Parameter name. 56 | /// 57 | public string Name 58 | { 59 | get { return _Name; } 60 | set { _Name = value; } 61 | } 62 | 63 | private double _Value; 64 | 65 | /// 66 | /// Parameter value. 67 | /// The linear units of a parameters' values match the linear units of the containing 68 | /// projected coordinate system. The angular units of parameter values match the 69 | /// angular units of the geographic coordinate system that the projected coordinate 70 | /// system is based on. 71 | /// 72 | public double Value 73 | { 74 | get { return _Value; } 75 | set { _Value = value; } 76 | } 77 | 78 | 79 | /// 80 | /// Returns the Well-known text for this object 81 | /// as defined in the simple features specification. 82 | /// 83 | public string WKT 84 | { 85 | get 86 | { 87 | return String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "PARAMETER[\"{0}\", {1}]", Name, Value); 88 | } 89 | } 90 | 91 | /// 92 | /// Gets an XML representation of this object 93 | /// 94 | public string XML 95 | { 96 | get 97 | { 98 | return String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "", Name, Value); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Projections/KrovakProjection.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/Projections/KrovakProjection.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Projections/TransverseMercator.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/Projections/TransverseMercator.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/ConcatenatedTransform.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | 26 | namespace ProjNet.CoordinateSystems.Transformations 27 | { 28 | /// 29 | /// 30 | /// 31 | internal class ConcatenatedTransform : MathTransform 32 | { 33 | /// 34 | /// 35 | /// 36 | protected IMathTransform? _inverse; 37 | 38 | /// 39 | /// 40 | /// 41 | public ConcatenatedTransform() : 42 | this(new List()) { } 43 | 44 | /// 45 | /// 46 | /// 47 | /// 48 | public ConcatenatedTransform(List transformlist) 49 | { 50 | _CoordinateTransformationList = transformlist; 51 | } 52 | 53 | private List _CoordinateTransformationList; 54 | 55 | /// 56 | /// 57 | /// 58 | public List CoordinateTransformationList 59 | { 60 | get { return _CoordinateTransformationList; } 61 | set 62 | { 63 | _CoordinateTransformationList = value; 64 | _inverse = null; 65 | } 66 | } 67 | 68 | /// 69 | /// Transforms a point 70 | /// 71 | /// 72 | /// 73 | public override double[] Transform(double[] point) 74 | { 75 | foreach (ICoordinateTransformation ct in _CoordinateTransformationList) 76 | point = ct.MathTransform.Transform(point); 77 | return point; 78 | } 79 | 80 | /// 81 | /// Transforms a list point 82 | /// 83 | /// 84 | /// 85 | public override List TransformList(List points) 86 | { 87 | List pnts = new List(points.Count); 88 | pnts.AddRange(points); 89 | foreach (ICoordinateTransformation ct in _CoordinateTransformationList) 90 | pnts = ct.MathTransform.TransformList(pnts); 91 | return pnts; 92 | } 93 | 94 | /// 95 | /// Returns the inverse of this conversion. 96 | /// 97 | /// IMathTransform that is the reverse of the current conversion. 98 | public override IMathTransform Inverse() 99 | { 100 | if (_inverse == null) 101 | { 102 | _inverse = this.Clone(); 103 | _inverse.Invert(); 104 | } 105 | return _inverse; 106 | } 107 | 108 | /// 109 | /// Reverses the transformation 110 | /// 111 | public override void Invert() 112 | { 113 | _CoordinateTransformationList.Reverse(); 114 | foreach (ICoordinateTransformation ic in _CoordinateTransformationList) 115 | ic.MathTransform.Invert(); 116 | } 117 | 118 | public ConcatenatedTransform Clone() 119 | { 120 | List clonedList = new List(_CoordinateTransformationList.Count); 121 | foreach (ICoordinateTransformation ct in _CoordinateTransformationList) 122 | clonedList.Add(ct); 123 | return new ConcatenatedTransform(clonedList); 124 | } 125 | 126 | /// 127 | /// Gets a Well-Known text representation of this object. 128 | /// 129 | /// 130 | public override string WKT 131 | { 132 | get { throw new NotImplementedException(); } 133 | } 134 | 135 | /// 136 | /// Gets an XML representation of this object. 137 | /// 138 | /// 139 | public override string XML 140 | { 141 | get { throw new NotImplementedException(); } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/CoordinateTransformation.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/Transformations/CoordinateTransformation.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/CoordinateTransformationAuthorityFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | namespace ProjNET.CoordinateSystems.Transformations 24 | { 25 | /// 26 | /// Creates coordinate transformation objects from codes. The codes are maintained by an external authority. A commonly used authority is EPSG, which is also used in the GeoTIFF standard 27 | /// 28 | public interface CoordinateTransformationAuthorityFactory 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/DatumTransform.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | 26 | namespace ProjNet.CoordinateSystems.Transformations 27 | { 28 | /// 29 | /// Transformation for applying 30 | /// 31 | internal class DatumTransform : MathTransform 32 | { 33 | protected IMathTransform? _inverse; 34 | private Wgs84ConversionInfo _ToWgs94; 35 | double[] v; 36 | 37 | private bool _isInverse = false; 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | /// 43 | public DatumTransform(Wgs84ConversionInfo towgs84) : this(towgs84,false) 44 | { 45 | } 46 | 47 | private DatumTransform(Wgs84ConversionInfo towgs84, bool isInverse) 48 | { 49 | _ToWgs94 = towgs84; 50 | v = _ToWgs94.GetAffineTransform(); 51 | _isInverse = isInverse; 52 | } 53 | /// 54 | /// Gets a Well-Known text representation of this object. 55 | /// 56 | /// 57 | public override string WKT 58 | { 59 | get { throw new NotImplementedException(); } 60 | } 61 | 62 | /// 63 | /// Gets an XML representation of this object. 64 | /// 65 | /// 66 | public override string XML 67 | { 68 | get { throw new NotImplementedException(); } 69 | } 70 | 71 | /// 72 | /// Creates the inverse transform of this object. 73 | /// 74 | /// 75 | /// This method may fail if the transform is not one to one. However, all cartographic projections should succeed. 76 | public override IMathTransform Inverse() 77 | { 78 | if (_inverse == null) 79 | _inverse = new DatumTransform(_ToWgs94,!_isInverse); 80 | return _inverse; 81 | } 82 | 83 | private double[] Apply(double[] p) 84 | { 85 | return new double[] { 86 | v[0] * p[0] - v[3] * p[1] + v[2] * p[2] + v[4], 87 | v[3] * p[0] + v[0] * p[1] - v[1] * p[2] + v[5], 88 | -v[2] * p[0] + v[1] * p[1] + v[0] * p[2] + v[6], }; 89 | } 90 | 91 | private double[] ApplyInverted(double[] p) 92 | { 93 | return new double[] { 94 | v[0] * p[0] + v[3] * p[1] - v[2] * p[2] - v[4], 95 | -v[3] * p[0] + v[0] * p[1] + v[1] * p[2] - v[5], 96 | v[2] * p[0] - v[1] * p[1] + v[0] * p[2] - v[6], }; 97 | } 98 | 99 | /// 100 | /// Transforms a coordinate point. The passed parameter point should not be modified. 101 | /// 102 | /// 103 | /// 104 | public override double[] Transform(double[] point) 105 | { 106 | if (!_isInverse) 107 | return Apply(point); 108 | else return ApplyInverted(point); 109 | } 110 | 111 | /// 112 | /// Transforms a list of coordinate point ordinal values. 113 | /// 114 | /// 115 | /// 116 | /// 117 | /// This method is provided for efficiently transforming many points. The supplied array 118 | /// of ordinal values will contain packed ordinal values. For example, if the source 119 | /// dimension is 3, then the ordinals will be packed in this order (x0,y0,z0,x1,y1,z1 ...). 120 | /// The size of the passed array must be an integer multiple of DimSource. The returned 121 | /// ordinal values are packed in a similar way. In some DCPs. the ordinals may be 122 | /// transformed in-place, and the returned array may be the same as the passed array. 123 | /// So any client code should not attempt to reuse the passed ordinal values (although 124 | /// they can certainly reuse the passed array). If there is any problem then the server 125 | /// implementation will throw an exception. If this happens then the client should not 126 | /// make any assumptions about the state of the ordinal values. 127 | /// 128 | public override List TransformList(List points) 129 | { 130 | List pnts = new List(points.Count); 131 | foreach (double[] p in points) 132 | pnts.Add(Transform(p)); 133 | return pnts; 134 | } 135 | 136 | /// 137 | /// Reverses the transformation 138 | /// 139 | public override void Invert() 140 | { 141 | _isInverse = !_isInverse; 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/DomainFlags.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems.Transformations 28 | { 29 | /// 30 | /// Flags indicating parts of domain covered by a convex hull. 31 | /// 32 | /// 33 | /// These flags can be combined. For example, the value 3 34 | /// corresponds to a combination of and , 35 | /// which means that some parts of the convex hull are inside the 36 | /// domain, and some parts of the convex hull are outside the domain. 37 | /// 38 | public enum DomainFlags : int 39 | { 40 | /// 41 | /// At least one point in a convex hull is inside the transform's domain. 42 | /// 43 | Inside = 1, 44 | /// 45 | /// At least one point in a convex hull is outside the transform's domain. 46 | /// 47 | Outside = 2, 48 | /// 49 | /// At least one point in a convex hull is not transformed continuously. 50 | /// 51 | /// 52 | /// As an example, consider a "Longitude_Rotation" transform which adjusts 53 | /// longitude coordinates to take account of a change in Prime Meridian. If 54 | /// the rotation is 5 degrees east, then the point (Lat=175,Lon=0) is not 55 | /// transformed continuously, since it is on the meridian line which will 56 | /// be split at +180/-180 degrees. 57 | /// 58 | Discontinuous = 4 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/GeographicTransform.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | 26 | namespace ProjNet.CoordinateSystems.Transformations 27 | { 28 | /// 29 | /// The GeographicTransform class is implemented on geographic transformation objects and 30 | /// implements datum transformations between geographic coordinate systems. 31 | /// 32 | public class GeographicTransform : MathTransform 33 | { 34 | internal GeographicTransform(IGeographicCoordinateSystem sourceGCS, IGeographicCoordinateSystem targetGCS) 35 | { 36 | _SourceGCS = sourceGCS; 37 | _TargetGCS = targetGCS; 38 | } 39 | 40 | #region IGeographicTransform Members 41 | 42 | private IGeographicCoordinateSystem _SourceGCS; 43 | 44 | /// 45 | /// Gets or sets the source geographic coordinate system for the transformation. 46 | /// 47 | public IGeographicCoordinateSystem SourceGCS 48 | { 49 | get { return _SourceGCS; } 50 | set { _SourceGCS = value; } 51 | } 52 | 53 | private IGeographicCoordinateSystem _TargetGCS; 54 | 55 | /// 56 | /// Gets or sets the target geographic coordinate system for the transformation. 57 | /// 58 | public IGeographicCoordinateSystem TargetGCS 59 | { 60 | get { return _TargetGCS; } 61 | set { _TargetGCS = value; } 62 | } 63 | 64 | /// 65 | /// Returns the Well-known text for this object 66 | /// as defined in the simple features specification. [NOT IMPLEMENTED]. 67 | /// 68 | public override string WKT 69 | { 70 | get 71 | { 72 | throw new NotImplementedException(); 73 | } 74 | } 75 | 76 | /// 77 | /// Gets an XML representation of this object [NOT IMPLEMENTED]. 78 | /// 79 | public override string XML 80 | { 81 | get 82 | { 83 | throw new NotImplementedException(); 84 | } 85 | } 86 | 87 | #endregion 88 | 89 | /// 90 | /// Creates the inverse transform of this object. 91 | /// 92 | /// This method may fail if the transform is not one to one. However, all cartographic projections should succeed. 93 | /// 94 | public override IMathTransform Inverse() 95 | { 96 | throw new NotImplementedException(); 97 | } 98 | 99 | /// 100 | /// Transforms a coordinate point. The passed parameter point should not be modified. 101 | /// 102 | /// 103 | /// 104 | public override double[] Transform(double[] point) 105 | { 106 | double[] pOut = (double[]) point.Clone(); 107 | pOut[0] /= SourceGCS.AngularUnit.RadiansPerUnit; 108 | pOut[0] -= SourceGCS.PrimeMeridian.Longitude / SourceGCS.PrimeMeridian.AngularUnit.RadiansPerUnit; 109 | pOut[0] += TargetGCS.PrimeMeridian.Longitude / TargetGCS.PrimeMeridian.AngularUnit.RadiansPerUnit; 110 | pOut[0] *= SourceGCS.AngularUnit.RadiansPerUnit; 111 | return pOut; 112 | } 113 | 114 | /// 115 | /// Transforms a list of coordinate point ordinal values. 116 | /// 117 | /// 118 | /// This method is provided for efficiently transforming many points. The supplied array 119 | /// of ordinal values will contain packed ordinal values. For example, if the source 120 | /// dimension is 3, then the ordinals will be packed in this order (x0,y0,z0,x1,y1,z1 ...). 121 | /// The size of the passed array must be an integer multiple of DimSource. The returned 122 | /// ordinal values are packed in a similar way. In some DCPs. the ordinals may be 123 | /// transformed in-place, and the returned array may be the same as the passed array. 124 | /// So any client code should not attempt to reuse the passed ordinal values (although 125 | /// they can certainly reuse the passed array). If there is any problem then the server 126 | /// implementation will throw an exception. If this happens then the client should not 127 | /// make any assumptions about the state of the ordinal values. 128 | /// 129 | /// 130 | /// 131 | public override List TransformList(List points) 132 | { 133 | List trans = new List(points.Count); 134 | foreach (double[] p in points) 135 | trans.Add(Transform(p)); 136 | return trans; 137 | } 138 | 139 | /// 140 | /// Reverses the transformation 141 | /// 142 | public override void Invert() 143 | { 144 | throw new NotImplementedException(); 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/ICoordinateSystemAuthorityFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Creates spatial reference objects using codes. 31 | /// 32 | /// 33 | /// The codes are maintained by an external authority. A commonly used authority is EPSG, which is also used in the GeoTIFF standard and in ProjNet. 34 | /// 35 | public interface ICoordinateSystemAuthorityFactory 36 | { 37 | /// 38 | /// Returns the authority name for this factory (e.g., "EPSG" or "POSC"). 39 | /// 40 | string Authority { get; } 41 | /// 42 | /// Returns a projected coordinate system object corresponding to the given code. 43 | /// 44 | /// The identification code. 45 | /// The projected coordinate system object with the given code. 46 | IProjectedCoordinateSystem CreateProjectedCoordinateSystem(long code); 47 | /// 48 | /// Returns a geographic coordinate system object corresponding to the given code. 49 | /// 50 | /// The identification code. 51 | /// The geographic coordinate system object with the given code. 52 | IGeographicCoordinateSystem CreateGeographicCoordinateSystem(long code); 53 | /// 54 | /// Returns a horizontal datum object corresponding to the given code. 55 | /// 56 | /// The identification code. 57 | /// The horizontal datum object with the given code. 58 | IHorizontalDatum CreateHorizontalDatum(long code); 59 | /// 60 | /// Returns an ellipsoid object corresponding to the given code. 61 | /// 62 | /// The identification code. 63 | /// The ellipsoid object with the given code. 64 | IEllipsoid CreateEllipsoid(long code); 65 | /// 66 | /// Returns a prime meridian object corresponding to the given code. 67 | /// 68 | /// The identification code. 69 | /// The prime meridian object with the given code. 70 | IPrimeMeridian CreatePrimeMeridian(long code); 71 | /// 72 | /// Returns a linear unit object corresponding to the given code. 73 | /// 74 | /// The identification code. 75 | /// The linear unit object with the given code. 76 | ILinearUnit CreateLinearUnit(long code); 77 | /// 78 | /// Returns an angular unit object corresponding to the given code. 79 | /// 80 | /// The identification code. 81 | /// The angular unit object for the given code. 82 | IAngularUnit CreateAngularUnit(long code); 83 | /// 84 | /// Creates a from a code. 85 | /// 86 | /// Authority code 87 | /// Vertical datum for the given code 88 | IVerticalDatum CreateVerticalDatum(long code); 89 | /// 90 | /// Create a vertical coordinate system from a code. 91 | /// 92 | /// Authority code 93 | /// 94 | IVerticalCoordinateSystem CreateVerticalCoordinateSystem(long code); 95 | /// 96 | /// Creates a 3D coordinate system from a code. 97 | /// 98 | /// Authority code 99 | /// Compound coordinate system for the given code 100 | ICompoundCoordinateSystem CreateCompoundCoordinateSystem(long code); 101 | /// 102 | /// Creates a horizontal co-ordinate system from a code. 103 | /// The horizontal coordinate system could be geographic or projected. 104 | /// 105 | /// Authority code 106 | /// Horizontal coordinate system for the given code 107 | IHorizontalCoordinateSystem CreateHorizontalCoordinateSystem(long code); 108 | /// 109 | /// Gets a description of the object corresponding to a code. 110 | /// 111 | string DescriptionText { get; } 112 | /// 113 | /// Gets the Geoid code from a WKT name. 114 | /// 115 | /// 116 | /// In the OGC definition of WKT horizontal datums, the geoid is referenced 117 | /// by a quoted string, which is used as a key value. This method converts 118 | /// the key value string into a code recognized by this authority. 119 | /// 120 | /// 121 | /// 122 | string GeoidFromWktName(string wkt); 123 | /// 124 | /// Gets the WKT name of a Geoid. 125 | /// 126 | /// 127 | /// In the OGC definition of WKT horizontal datums, the geoid is referenced by 128 | /// a quoted string, which is used as a key value. This method gets the OGC WKT 129 | /// key value from a geoid code. 130 | /// 131 | /// 132 | /// 133 | string WktGeoidName(string geoid); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/ICoordinateTransformation.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/Transformations/ICoordinateTransformation.cs -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/ICoordinateTransformationAuthorityFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | namespace ProjNet.CoordinateSystems.Transformations 24 | { 25 | /// 26 | /// Creates coordinate transformation objects from codes. The codes are maintained by an external authority. A commonly used authority is EPSG, which is also used in the GeoTIFF standard 27 | /// 28 | public interface ICoordinateTransformationAuthorityFactory 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/ICoordinateTransformationFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems.Transformations 28 | { 29 | /// 30 | /// Creates coordinate transformations. 31 | /// 32 | public interface ICoordinateTransformationFactory 33 | { 34 | /// 35 | /// Creates a transformation between two coordinate systems. 36 | /// 37 | /// 38 | /// This method will examine the coordinate systems in order to construct 39 | /// a transformation between them. This method may fail if no path between 40 | /// the coordinate systems is found, using the normal failing behavior of 41 | /// the DCP (e.g. throwing an exception). 42 | /// Source coordinate system 43 | /// Target coordinate system 44 | /// 45 | ICoordinateTransformation CreateFromCoordinateSystems(ICoordinateSystem sourceCS, ICoordinateSystem targetCS); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/IMathTransform.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems.Transformations 28 | { 29 | /// 30 | /// Transforms muti-dimensional coordinate points. 31 | /// 32 | /// 33 | /// If a client application wishes to query the source and target coordinate 34 | /// systems of a transformation, then it should keep hold of the 35 | /// interface, and use the contained 36 | /// math transform object whenever it wishes to perform a transform. 37 | /// 38 | public interface IMathTransform 39 | { 40 | /// 41 | /// Gets the dimension of input points. 42 | /// 43 | int DimSource { get; } 44 | 45 | /// 46 | /// Gets the dimension of output points. 47 | /// 48 | int DimTarget { get; } 49 | 50 | /// 51 | /// Tests whether this transform does not move any points. 52 | /// 53 | /// 54 | bool Identity(); 55 | 56 | /// 57 | /// Gets a Well-Known text representation of this object. 58 | /// 59 | string WKT { get; } 60 | 61 | /// 62 | /// Gets an XML representation of this object. 63 | /// 64 | string XML { get; } 65 | 66 | /// 67 | /// Gets the derivative of this transform at a point. If the transform does 68 | /// not have a well-defined derivative at the point, then this function should 69 | /// fail in the usual way for the DCP. The derivative is the matrix of the 70 | /// non-translating portion of the approximate affine map at the point. The 71 | /// matrix will have dimensions corresponding to the source and target 72 | /// coordinate systems. If the input dimension is M, and the output dimension 73 | /// is N, then the matrix will have size [M][N]. The elements of the matrix 74 | /// {elt[n][m] : n=0..(N-1)} form a vector in the output space which is 75 | /// parallel to the displacement caused by a small change in the m'th ordinate 76 | /// in the input space. 77 | /// 78 | /// 79 | /// 80 | double[,] Derivative(double[] point); 81 | 82 | /// 83 | /// Gets transformed convex hull. 84 | /// 85 | /// 86 | /// The supplied ordinates are interpreted as a sequence of points, which generates a convex 87 | /// hull in the source space. The returned sequence of ordinates represents a convex hull in the 88 | /// output space. The number of output points will often be different from the number of input 89 | /// points. Each of the input points should be inside the valid domain (this can be checked by 90 | /// testing the points' domain flags individually). However, the convex hull of the input points 91 | /// may go outside the valid domain. The returned convex hull should contain the transformed image 92 | /// of the intersection of the source convex hull and the source domain. 93 | /// A convex hull is a shape in a coordinate system, where if two positions A and B are 94 | /// inside the shape, then all positions in the straight line between A and B are also inside 95 | /// the shape. So in 3D a cube and a sphere are both convex hulls. Other less obvious examples 96 | /// of convex hulls are straight lines, and single points. (A single point is a convex hull, 97 | /// because the positions A and B must both be the same - i.e. the point itself. So the straight 98 | /// line between A and B has zero length.) 99 | /// Some examples of shapes that are NOT convex hulls are donuts, and horseshoes. 100 | /// 101 | /// 102 | /// 103 | List GetCodomainConvexHull(List points); 104 | 105 | /// 106 | /// Gets flags classifying domain points within a convex hull. 107 | /// 108 | /// 109 | /// The supplied ordinates are interpreted as a sequence of points, which 110 | /// generates a convex hull in the source space. Conceptually, each of the 111 | /// (usually infinite) points inside the convex hull is then tested against 112 | /// the source domain. The flags of all these tests are then combined. In 113 | /// practice, implementations of different transforms will use different 114 | /// short-cuts to avoid doing an infinite number of tests. 115 | /// 116 | /// 117 | /// 118 | DomainFlags GetDomainFlags(List points); 119 | 120 | /// 121 | /// Creates the inverse transform of this object. 122 | /// 123 | /// This method may fail if the transform is not one to one. However, all cartographic projections should succeed. 124 | /// 125 | IMathTransform Inverse(); 126 | 127 | /// 128 | /// Transforms a coordinate point. The passed parameter point should not be modified. 129 | /// 130 | /// 131 | /// 132 | double[] Transform(double[] point); 133 | 134 | /// 135 | /// Transforms a list of coordinate point ordinal values. 136 | /// 137 | /// 138 | /// This method is provided for efficiently transforming many points. The supplied array 139 | /// of ordinal values will contain packed ordinal values. For example, if the source 140 | /// dimension is 3, then the ordinals will be packed in this order (x0,y0,z0,x1,y1,z1 ...). 141 | /// The size of the passed array must be an integer multiple of DimSource. The returned 142 | /// ordinal values are packed in a similar way. In some DCPs. the ordinals may be 143 | /// transformed in-place, and the returned array may be the same as the passed array. 144 | /// So any client code should not attempt to reuse the passed ordinal values (although 145 | /// they can certainly reuse the passed array). If there is any problem then the server 146 | /// implementation will throw an exception. If this happens then the client should not 147 | /// make any assumptions about the state of the ordinal values. 148 | /// 149 | /// 150 | /// 151 | List TransformList(List points); 152 | 153 | /// 154 | /// Reverses the transformation 155 | /// 156 | void Invert(); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/IMathTransformFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems.Transformations 28 | { 29 | /// 30 | /// Creates math transforms. 31 | /// 32 | /// 33 | /// CT_MathTransformFactory is a low level factory that is used to create CT_MathTransform objects. Many high level GIS applications will never need to use a CT_MathTransformFactory directly; they can use a CT_CoordinateTransformationFactory instead. However, the CT_MathTransformFactory interface is specified here, since it can be used directly by applications that wish to transform other types of coordinates (e.g. color coordinates, or image pixel coordinates). 34 | /// The following comments assume that the same vendor implements the math transform factory interfaces and math transform interfaces. 35 | /// A math transform is an object that actually does the work of applying formulae to coordinate values. The math transform does not know or care how the coordinates relate to positions in the real world. This lack of semantics makes implementing CT_MathTransformFactory significantly easier than it would be otherwise. 36 | /// For example CT_MathTransformFactory can create affine math transforms. The affine transform applies a matrix to the coordinates without knowing how what it is doing relates to the real world. So if the matrix scales Z values by a factor of 1000, then it could be converting meters into millimeters, or it could be converting kilometers into meters. 37 | /// Because math transforms have low semantic value (but high mathematical value), programmers who do not have much knowledge of how GIS applications use coordinate systems, or how those coordinate systems relate to the real world can implement CT_MathTransformFactory. 38 | /// The low semantic content of math transforms also means that they will be useful in applications that have nothing to do with GIS coordinates. For example, a math transform could be used to map color coordinates between different color spaces, such as converting (red, green, blue) colors into (hue, light, saturation) colors. 39 | /// Since a math transform does not know what its source and target coordinate systems mean, it is not necessary or desirable for a math transform object to keep information on its source and target coordinate systems. 40 | /// 41 | public interface IMathTransformFactory 42 | { 43 | /// 44 | /// Creates an affine transform from a matrix. 45 | /// 46 | /// If the transform's input dimension is M, and output dimension is N, then the matrix will have size [N+1][M+1]. The +1 in the matrix dimensions allows the matrix to do a shift, as well as a rotation. The [M][j] element of the matrix will be the j'th ordinate of the moved origin. The [i][N] element of the matrix will be 0 for i less than M, and 1 for i equals M. 47 | /// 48 | /// 49 | MathTransform CreateAffineTransform(double[,] matrix); 50 | /// 51 | /// Creates a transform by concatenating two existing transforms. A concatenated transform acts in the same way as applying two transforms, one after the other. 52 | /// 53 | /// The dimension of the output space of the first transform must match the dimension of the input space in the second transform. If you wish to concatenate more than two transforms, then you can repeatedly use this method. 54 | /// 55 | /// 56 | /// 57 | MathTransform CreateConcatenatedTransform(MathTransform transform1, MathTransform transform2); 58 | /// 59 | /// Creates a math transform from a Well-Known Text string. 60 | /// 61 | /// 62 | /// 63 | MathTransform CreateFromWKT(string wkt); 64 | /// 65 | /// Creates a math transform from XML. 66 | /// 67 | /// 68 | /// 69 | MathTransform CreateFromXML(string xml); 70 | /// 71 | /// Creates a transform from a classification name and parameters. 72 | /// 73 | /// 74 | /// The client must ensure that all the linear parameters are expressed in meters, and all the angular parameters are expressed in degrees. Also, they must supply "semi_major" and "semi_minor" parameters for cartographic projection transforms. 75 | /// 76 | /// 77 | /// 78 | /// 79 | MathTransform CreateParameterizedTransform(string classification, List parameters); 80 | /// 81 | /// Creates a transform which passes through a subset of ordinates to another transform. 82 | /// 83 | /// 84 | /// This allows transforms to operate on a subset of ordinates. For example, if you have (Lat,Lon,Height) coordinates, then you may wish to convert the height values from meters to feet without affecting the (Lat,Lon) values. If you wanted to affect the (Lat,Lon) values and leave the Height values alone, then you would have to swap the ordinates around to (Height,Lat,Lon). You can do this with an affine map. 85 | /// 86 | /// 87 | /// 88 | /// 89 | MathTransform CreatePassThroughTransform(int firstAffectedOrdinate, MathTransform subTransform); 90 | /// 91 | /// Tests whether parameter is angular. Clients must ensure that all angular parameter values are in degrees. 92 | /// 93 | /// 94 | /// 95 | bool IsParameterAngular(string parameterName); 96 | /// 97 | /// Tests whether parameter is linear. Clients must ensure that all linear parameter values are in meters. 98 | /// 99 | /// 100 | /// 101 | bool IsParameterLinear(string parameterName); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Transformations/TransformType.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Collections.Generic; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems.Transformations 28 | { 29 | /// 30 | /// Semantic type of transform used in coordinate transformation. 31 | /// 32 | public enum TransformType : int 33 | { 34 | /// 35 | /// Unknown or unspecified type of transform. 36 | /// 37 | Other = 0, 38 | /// 39 | /// Transform depends only on defined parameters. For example, a cartographic projection. 40 | /// 41 | Conversion = 1, 42 | /// 43 | /// Transform depends only on empirically derived parameters. For example a datum transformation. 44 | /// 45 | Transformation = 2, 46 | /// 47 | /// Transform depends on both defined and empirical parameters. 48 | /// 49 | ConversionAndTransformation = 3 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/Unit.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | using System; 24 | using System.Globalization; 25 | using System.Text; 26 | 27 | namespace ProjNet.CoordinateSystems 28 | { 29 | /// 30 | /// Class for defining units 31 | /// 32 | public class Unit : Info, IUnit 33 | { 34 | /// 35 | /// Initializes a new unit 36 | /// 37 | /// Conversion factor to base unit 38 | /// Name of unit 39 | /// Authority name 40 | /// Authority-specific identification code. 41 | /// Alias 42 | /// Abbreviation 43 | /// Provider-supplied remarks 44 | internal Unit(double conversionFactor, string name, string authority, long authorityCode, string alias, string abbreviation, string remarks) 45 | : 46 | base(name, authority, authorityCode, alias, abbreviation, remarks) 47 | { 48 | _ConversionFactor = conversionFactor; 49 | } 50 | 51 | /// 52 | /// Initializes a new unit 53 | /// 54 | /// Name of unit 55 | /// Conversion factor to base unit 56 | internal Unit(string name, double conversionFactor) 57 | : this(conversionFactor, name, String.Empty, -1, String.Empty, String.Empty, String.Empty) 58 | { 59 | } 60 | 61 | private double _ConversionFactor; 62 | 63 | /// 64 | /// Gets or sets the number of units per base-unit. 65 | /// 66 | public double ConversionFactor 67 | { 68 | get { return _ConversionFactor; } 69 | set { _ConversionFactor = value; } 70 | } 71 | 72 | /// 73 | /// Returns the Well-known text for this object 74 | /// as defined in the simple features specification. 75 | /// 76 | public override string WKT 77 | { 78 | get 79 | { 80 | StringBuilder sb = new StringBuilder(); 81 | sb.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "UNIT[\"{0}\", {1}", Name, _ConversionFactor); 82 | if (!String.IsNullOrEmpty(Authority) && AuthorityCode > 0) 83 | sb.AppendFormat(", AUTHORITY[\"{0}\", \"{1}\"]", Authority, AuthorityCode); 84 | sb.Append("]"); 85 | return sb.ToString(); 86 | } 87 | } 88 | 89 | /// 90 | /// Gets an XML representation of this object [NOT IMPLEMENTED]. 91 | /// 92 | public override string XML 93 | { 94 | get 95 | { 96 | throw new NotImplementedException(); 97 | } 98 | } 99 | 100 | /// 101 | /// Checks whether the values of this instance is equal to the values of another instance. 102 | /// Only parameters used for coordinate system are used for comparison. 103 | /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. 104 | /// 105 | /// 106 | /// True if equal 107 | public override bool EqualParams(object obj) 108 | { 109 | if (!(obj is Unit u)) 110 | return false; 111 | return u.ConversionFactor == this.ConversionFactor; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/ProjNET/CoordinateSystems/WGS84ConversionInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/ProjNET/950d303af8213f9b17413617bb6942e2ce1939b5/src/ProjNET/CoordinateSystems/WGS84ConversionInfo.cs -------------------------------------------------------------------------------- /src/ProjNET/IO/CoordinateSystems/TokenType.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | // SOURCECODE IS MODIFIED FROM ANOTHER WORK AND IS ORIGINALLY BASED ON GeoTools.NET: 24 | /* 25 | * Copyright (C) 2002 Urban Science Applications, Inc. 26 | * 27 | * This library is free software; you can redistribute it and/or 28 | * modify it under the terms of the GNU Lesser General Public 29 | * License as published by the Free Software Foundation; either 30 | * version 2.1 of the License, or (at your option) any later version. 31 | * 32 | * This library is distributed in the hope that it will be useful, 33 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35 | * Lesser General Public License for more details. 36 | * 37 | * You should have received a copy of the GNU Lesser General Public 38 | * License along with this library; if not, write to the Free Software 39 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 40 | * 41 | */ 42 | 43 | #region Using 44 | 45 | 46 | 47 | #endregion 48 | 49 | namespace ProjNet.Converters.WellKnownText 50 | { 51 | /// 52 | /// Represents the type of token created by the StreamTokenizer class. 53 | /// 54 | internal enum TokenType 55 | { 56 | /// 57 | /// Indicates that the token is a word. 58 | /// 59 | Word, 60 | /// 61 | /// Indicates that the token is a number. 62 | /// 63 | Number, 64 | /// 65 | /// Indicates that the end of line has been read. The field can only have this value if the eolIsSignificant method has been called with the argument true. 66 | /// 67 | Eol, 68 | /// 69 | /// Indicates that the end of the input stream has been reached. 70 | /// 71 | Eof, 72 | /// 73 | /// Indictaes that the token is white space (space, tab, newline). 74 | /// 75 | Whitespace, 76 | /// 77 | /// Characters that are not whitespace, numbers, etc... 78 | /// 79 | Symbol 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/ProjNET/IO/CoordinateSystems/WKTStreamTokenizer.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2005 - 2020 - Morten Nielsen (www.xaml.dev) 2 | // 3 | // This file is part of ProjNet. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | // software and associated documentation files (the "Software"), to deal in the Software 9 | // without restriction, including without limitation the rights to use, copy, modify, merge, 10 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | // to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or 14 | // substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | 23 | 24 | // SOURCECODE IS MODIFIED FROM ANOTHER WORK AND IS ORIGINALLY BASED ON GeoTools.NET: 25 | /* 26 | * Copyright (C) 2002 Urban Science Applications, Inc. 27 | * 28 | * This library is free software; you can redistribute it and/or 29 | * modify it under the terms of the GNU Lesser General Public 30 | * License as published by the Free Software Foundation; either 31 | * version 2.1 of the License, or (at your option) any later version. 32 | * 33 | * This library is distributed in the hope that it will be useful, 34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | * Lesser General Public License for more details. 37 | * 38 | * You should have received a copy of the GNU Lesser General Public 39 | * License along with this library; if not, write to the Free Software 40 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 41 | * 42 | */ 43 | 44 | using System; 45 | using System.Globalization; 46 | using System.IO; 47 | using ProjNet.Converters.WellKnownText.IO; 48 | 49 | namespace ProjNet.Converters.WellKnownText 50 | { 51 | /// 52 | /// Reads a stream of Well Known Text (wkt) string and returns a stream of tokens. 53 | /// 54 | internal class WktStreamTokenizer : StreamTokenizer 55 | { 56 | 57 | #region Constructors 58 | 59 | /// 60 | /// Initializes a new instance of the WktStreamTokenizer class. 61 | /// 62 | /// The WktStreamTokenizer class ais in reading WKT streams. 63 | /// A TextReader that contains 64 | public WktStreamTokenizer(TextReader reader) : base(reader, true) 65 | { 66 | if (reader==null) 67 | { 68 | throw new ArgumentNullException("reader"); 69 | } 70 | } 71 | #endregion 72 | 73 | #region Methods 74 | 75 | /// 76 | /// Reads a token and checks it is what is expected. 77 | /// 78 | /// The expected token. 79 | internal void ReadToken(string expectedToken) 80 | { 81 | this.NextToken(); 82 | if (this.GetStringValue()!=expectedToken) 83 | { 84 | throw new ArgumentException(String.Format(CultureInfo.InvariantCulture.NumberFormat, "Expecting ('{3}') but got a '{0}' at line {1} column {2}.", this.GetStringValue(), this.LineNumber, this.Column, expectedToken)); 85 | } 86 | } 87 | 88 | /// 89 | /// Reads a string inside double quotes. 90 | /// 91 | /// 92 | /// White space inside quotes is preserved. 93 | /// 94 | /// The string inside the double quotes. 95 | public string ReadDoubleQuotedWord() 96 | { 97 | string word=""; 98 | ReadToken("\""); 99 | NextToken(false); 100 | while (GetStringValue()!="\"") 101 | { 102 | word = word+ this.GetStringValue(); 103 | NextToken(false); 104 | } 105 | return word; 106 | } 107 | 108 | /// 109 | /// Reads the authority and authority code. 110 | /// 111 | /// String to place the authority in. 112 | /// String to place the authority code in. 113 | public void ReadAuthority(ref string authority,ref long authorityCode) 114 | { 115 | //AUTHORITY["EPGS","9102"]] 116 | if(GetStringValue() != "AUTHORITY") 117 | ReadToken("AUTHORITY"); 118 | ReadToken("["); 119 | authority = this.ReadDoubleQuotedWord(); 120 | ReadToken(","); 121 | #if(!Silverlight) 122 | long.TryParse(this.ReadDoubleQuotedWord(), 123 | NumberStyles.Any, 124 | CultureInfo.InvariantCulture.NumberFormat, 125 | out authorityCode); 126 | #else 127 | try { authorityCode = long.Parse(this.ReadDoubleQuotedWord(), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); } 128 | catch { } 129 | #endif 130 | ReadToken("]"); 131 | } 132 | #endregion 133 | 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/ProjNET/ProjNET.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard1.0 5 | ProjNET 6 | ProjNET 7 | true 8 | Morten Nielsen 9 | 1.2.0 10 | Morten Nielsen 11 | 12 | © Morten Nielsen 2005-2009 13 | Projection, Coordinate Systems, GIS 14 | MIT 15 | https://github.com/dotMorten/ProjNET 16 | https://github.com/dotMorten/ProjNET 17 | true 18 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb 19 | git 20 | 8.0 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------