terriajs icon indicating copy to clipboard operation
terriajs copied to clipboard

Refactor use of proj4 lookup service (or find alternative)

Open nf-s opened this issue 10 months ago • 3 comments

TerriaJS-server has a proj4 lookup services to go from EPSG code to proj4 string. This is needed to reproject coordinates. The issue with the proj4 lookup services is that it requires an asynchronous call to be made - which can be complicated in certain bits of Terria's model layer.

One example is calculating the rectangle (i.e. bounding box) for a catalog item that requires coordinates to be reprojected - like here

https://github.com/TerriaJS/terriajs/blob/d8d90775a4b7e1de253b6eb31c9501d3f8ac3cfe/lib/Models/Catalog/Esri/ArcGisMapServerCatalogItem.ts#L238-L258

We could create a new LoadableStratum - but it would add complexity.

Terria has a "local" proj4 lookup here - https://github.com/TerriaJS/terriajs/blob/d8d90775a4b7e1de253b6eb31c9501d3f8ac3cfe/lib/Map/Vector/Proj4Definitions.ts - but it is very incomplete. We probably shouldn't include all proj4 strings - as it may be quite large.

Also, there is inconsistent use of the Proj4 lookup service across the code-base.

nf-s avatar Oct 11 '23 05:10 nf-s

@nf-s From a Victorian perspective there are key projections that are consistently and regularly used such as VicGrid (EPSG:3111 and EPSG:7899). All proj4 strings in that definition file is overkill, but a per-country or per-state proj4 file might be more manageable? It would definitely be handy to have those projections available.

Jonny-DELWP avatar Oct 12 '23 05:10 Jonny-DELWP

Should additional definitions be a config Param?

ljowen avatar Aug 16 '24 05:08 ljowen

Yeah that's a good idea! At least then we can add strings without building a new version

nf-s avatar Aug 18 '24 03:08 nf-s