Closed scuerda closed 8 years ago
@drnextgis you submitted the projection support code on #34, any views on this?
@amercader @drnextgis
I can see a few possible solutions. The geoview package could build a set of internal tables containing the proj4 strings. This could build off epsg.io. But this seems like a longer term endeavor. An more lightweight alternative would be allow the definition of deployment-specific proj4 ids and corresponding strings in the .ini which could then be passed in to the script as an array of accepted ids.
proj4js has the following convention:
proj4.defs([
[
'EPSG:4326',
'+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees'],
[
'EPSG:4269',
'+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees'
]
]);
Then, as long as the geojson uses an CRS id that maps to a a value in the array, the reprojection should just work.
Another alternative might be to use the epsg.io api to retrieve the proj4 string but I'm not sure the terms and conditions would allow widespread use.
I am happy to start plugging away at this if there is not already an existing solution that I have missed.
I think that using of epsg.io is not a good idea. This website is often down (at least returns 503 HTTP Error), moreover CKAN can be used inside LAN without Internet access. If you want to use custom CRSs for your GeoJSON file you have to do the following steps:
proj4defs.js
file with proj4 definitions like in your example above.Add link to this file to geojson
section of Fanstatic resource.config
file:
geojson =
...
js/proj4defs.js
NOTE: epsg.io already is used here.
@scuerda can we close this issue?
Yep. This is an acceptable solution.
Hi @drnextgis the resource.config
is that one inside /usr/lib/ckan/default/src/ckan/ckan/public/base/javascript
folder?
Thank you
For anyone finding this issue I can confirm, that this approach still works. We added additional definitions recently. However for CKAN 2.9 you need to include the new proj4defs.js
in the webassets.yml
file. Otherwise CKAN won't serve the file (see the CKAN documentation).
Proj4Leaflet requires that a projection definition statement is included. Something like:
proj4.defs("EPSG:26910", "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs");
Should be trivial to pull out the projection from the geojson CRS property, but still necessary to find a way to populate the definition with the actual proj4 string.