Select to view content in your preferred language

Features are created at lat,lon=[0,0] when changing spatial reference of FeatureCollectionTable

659
2
Jump to solution
07-19-2023 07:32 AM
padmalcom
Frequent Contributor

Hi, we are creating an empty map with a spatial reference of wkid 4326, and then add a wmsLayer as well as a feature collection layer. With the wkid 4326, features and map is displayed nicely but when we change the wkid to 3857, only the new wms layer shows correctly and all features from poiFeeatureCollectionLayer are created at lat=0, lon=0.

We use a constant for the spatial reference, so that I'm sure to have changed the spatial reference everywhere. I furthermore validated, that the lat and lon values we get from the backend are set correctly.

Do you suspect any error in my setup? I do not really understand why changing the spatial reference sets the features position to [0,0].

val wmsLayer = WmsLayer(Endpoints.WMS_LAYER_URL, listOf(Endpoints.WMS_LAYER_NAME))
mapView.map = ArcGISMap(SPATIAL_REFERENCE)
wmsLayer.load()
.onSuccess {
Timber.d("WmsLayer loaded with status ${wmsLayer.loadStatus.value}")
wmsLayer.let {
Timber.d("There are ${wmsLayer.layerInfos.size} wms layers")
mapView.map!!.apply {
operationalLayers.add(wmsLayer)
operationalLayers.add(poiFeatureCollectionLayer)
}
}
}
.onFailure {
Timber.d("Wms Layer load failed with status ${wmsLayer.loadStatus.value}")
}

 

0 Kudos
1 Solution

Accepted Solutions
MikeWilburn
Esri Contributor

Hi @padmalcom. WKID 4326 (WGS '84) is a spatial reference whose positional units are expressed in degrees, whereas WKID 3857 (Web Mercator) is a spatial reference whose positional units are expressed in meters.

When toggling the map's spatial reference from 4326 to 3857, without handling any change to the underlying coordinates of the data being added to the map, lat/lon values are being interpreted in meters and likely appearing mere hundreds of meters from 0, 0.

If you'd like to represent your data in 3857, you'll need to use GeometryEngine.projectOrNull(Geometry, SpatialReference) in order to correctly reproject the data.

View solution in original post

0 Kudos
2 Replies
MikeWilburn
Esri Contributor

Hi @padmalcom. WKID 4326 (WGS '84) is a spatial reference whose positional units are expressed in degrees, whereas WKID 3857 (Web Mercator) is a spatial reference whose positional units are expressed in meters.

When toggling the map's spatial reference from 4326 to 3857, without handling any change to the underlying coordinates of the data being added to the map, lat/lon values are being interpreted in meters and likely appearing mere hundreds of meters from 0, 0.

If you'd like to represent your data in 3857, you'll need to use GeometryEngine.projectOrNull(Geometry, SpatialReference) in order to correctly reproject the data.

0 Kudos
padmalcom
Frequent Contributor

Awesome @MikeWilburn, thank you very much!