wroge / wgs84

A zero-dependency Go package for coordinate transformations.
MIT License
116 stars 14 forks source link

generating factories out of WKT v1 (geotools epsg.properties) #4

Open fikin opened 11 months ago

fikin commented 11 months ago

hi,

i'm toying with the idea of tapping into geotools wkt epsg.properties and script/generate transformation factories for each definition. or simply parse wkt1, not decided yet.

perhaps parameterize MGI -> helmert with parameters from TOWGS84 definitions. and then instrument transverseMercator with PROPERTY values.

how do you see it, would it be working approach en mass? what would "area" function be then?

wroge commented 11 months ago

I have also considered using the different definition files (WKT, Proj4js, Proj.4) to derive the coordinate reference systems. However, many projections and transformations (e.g. GRID-based transformations like OSTN15_NTv2_OSGBtoETRS) are still missing in this library so that it has not yet been worthwhile from my point of view. Here is a document with most of the projections: https://drive.tiny.cloud/1/4m326iu12oa8re9cjiadxonharclteqb4mumfxj71zsttwkx/d6ce146d-81c5-423b-8cdb-1b66e801e167
It is certainly already possible to generate the code for the missing projections from this document with an AI. Maybe that's the reason why I couldn't get up the nerve to do this by hand yet :D

If you want to generate the EPSG codes with already existing projections and transformations, I would be happy about pull requests. The area function can simply always return true and then cause no harm. But I'm not really happy with the structure anymore and I'm thinking about releasing a new version.

fikin commented 11 months ago

alright, lets see if i manage to drive this generation to some meaningful results to post a pull request. and thanks for the pointer, apparently i had part 1 only and was missing the formulas ...

fikin commented 11 months ago

let me follow up on this and brainstorm together how to go about it. btw, as a background i'm casual bystander to geo projection topics, so don't expect me to show deep understanding on the subject.

as an example i'm looking at one of the provided definitions from GeoTools:

PROJCS["MGI / Austria M31", 
  GEOGCS["MGI", 
    DATUM["Militar-Geographische Institut", 
      SPHEROID["Bessel 1841", 6377397.155, 299.1528128, 
        AUTHORITY["EPSG", "7004"]], 
      TOWGS84[601.705, 84.263, 485.227, 4.7354, -1.3145, -5.393, -2.3887], 
      AUTHORITY["EPSG", "6312"]], 
    PRIMEM["Greenwich", 0.0, 
      AUTHORITY["EPSG", "8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Geodetic longitude", EAST], 
    AXIS["Geodetic latitude", NORTH], 
    AUTHORITY["EPSG", "4312"]], 
  PROJECTION["Transverse_Mercator", 
    AUTHORITY["EPSG", "9807"]], 
  PARAMETER["central_meridian", 13.333333333333336], 
  PARAMETER["latitude_of_origin", 0.0], 
  PARAMETER["scale_factor", 1.0], 
  PARAMETER["false_easting", 450000.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m", 1.0], 
  AXIS["Easting", EAST], 
  AXIS["Northing", NORTH], 
  AUTHORITY["EPSG", "31285"]] 

am i assuming right that this would result in:

helmert{
    tx: 601.705,
    ty: 84.263,
    tz: 485.227,
    rx: 4.7354,
    ry: -1.3145,
    rz: -5.393,
    ds: -2.3887,
}

and TransverseMercator(10.33333333333333, 0, 1, 450000, 0) ?

wroge commented 11 months ago
epsg31285 := Helmert(6377397.155, 299.1528128, 601.705, 84.263, 485.227, 4.7354, -1.3145, -5.393, -2.3887).TransverseMercator(13.333333333333336, 0, 1, 450000.0, 0)