EPSG:4326 projections in 2D mode

108 views
Skip to first unread message

poss...@systemsdefinition.com

unread,
Sep 5, 2017, 6:53:00 PM9/5/17
to TerriaJS
Hello. My project has a requirement to use a map server with the EPSG:4326 projection. Is there anything I can do to enable that projection when in 2D mode? I've successfully used that projection in a standalone Leaflet implementation in a different app. 

I read issue #2371 from 2 years ago, so I made some basic hardcoded changes to the source, but without success:

In node_modules/terriajs/lib/ViewModels/TerriaViewer.js, I added the crs property in selectLeaflet():
map = L.map(this._mapContainer, {
    zoomControl
: false,
    attributionControl
: false,
    maxZoom
: this.maximumLeafletZoomLevel,
    zoomSnap
: 1, // Change to  0.2 for incremental zoom when Chrome fixes canvas scaling gaps
    preferCanvas
: true,
    worldCopyJump
: true,
    crs: L.CRS.EPSG4326    //my change here
}).setView([-28.5, 135], 5);



And since I'm using an ArcGIS server, in node_modules/terriajs/lib/Models/ArcGisMapServerCatalogItem.js, I changed the tiling scheme in _createImageryProvider():
var imageryProvider = new ArcGisMapServerImageryProvider({
    url
: cleanAndProxyUrl(this, baseUrl),
    layers
: getLayerList(this),
    tilingScheme: new GeographicTillingScheme(),  //my change here
    maximumLevel
: maximumLevel,
    mapServerData
: this._mapServerData,
    enablePickFeatures
: defaultValue(this.allowFeaturePicking, true)

});


Following up from my previous posts, I've pulled the latest version of Terria, so I'm on 5.2.11.

Thanks, 
Bart


Kevin Ring

unread,
Sep 5, 2017, 8:41:29 PM9/5/17
to TerriaJS
Hi Bart,

I'm not sure what would be involved in this.  As far as I know, Leaflet has no support for mixing layers with different projections on the same map, which means all your layers would have to be EPSG:4326.  And that means all the base maps (which use EPSG:3857) aren't going to work.  Other than that, it should be possible, but I haven't tried to do it myself.  Take a look at lib/Map/CesiumTileLayer.js.  Despite the somewhat misleading name, that's the class that puts Cesium imagery layers onto the Leaflet map (in TerriaJS, all raster layers are Cesium ImageryLayers).  You'll see there's logic in there to explicitly reject non-EPSG:3857 layers, so that will definitely have to change.  I'll be interested to hear how you go!

Kevin


--
You received this message because you are subscribed to the Google Groups "TerriaJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terriajs+unsubscribe@googlegroups.com.
To post to this group, send email to terr...@googlegroups.com.
Visit this group at https://groups.google.com/group/terriajs.
For more options, visit https://groups.google.com/d/optout.



--

poss...@systemsdefinition.com

unread,
Sep 6, 2017, 12:18:55 PM9/6/17
to TerriaJS
Thanks, Kevin. Your suggestion worked perfectly, in conjunction with my changes above. I need to modify the basemaps anyway, and hardcoding a single projection is ok for now. I saw an old pull request from a couple years ago to configure basemaps through a file that I may want to revisit once I get a little more familiar with the codebase. 

Bart
To unsubscribe from this group and stop receiving emails from it, send an email to terriajs+u...@googlegroups.com.

To post to this group, send email to terr...@googlegroups.com.
Visit this group at https://groups.google.com/group/terriajs.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages