I have code in OpenLayers, which allows you to draw geometries on a layer and then download the file in GeoJSON format.
Here's the code:
function downloadGeoJSON(content, fileName, contentType) { var a = document.createElement("a"); var file = new Blob([content], { type: contentType }); a.href = URL.createObjectURL(file); a.download = fileName; a.click(); } var json = new ol.format.GeoJSON().writeFeatures(vector_layer.getSource().getFeatures(), { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' }); downloadGeoJSON(json, 'my_layer.geojson', 'text/plain'); Note: in the file, the features are saved with geographic CRS EPSG:4326, units in degree.
Then I can upload GeoJSON file. When the file was created in the OpenLayers application, the download works correctly. However, this file may have been created in QGIS, in EPSG:31983 with the unit in meters. In this case, how should I resolve it?
I need to convert to EPSG:4326 units in degrees, but I can't.
This is an example of geometry that is in file EPSG:31983
"geometry": { "type": "Point", "coordinates": [ 342273.613602064666338, 7384707.507063377648592 ] }
This is an example of geometry that is in file 4326
"type":"Point","coordinates":[-46.526534460937505,-23.653072477438627]}
Here is the upload code:
myFile.files[0].text().then(function (text) { vector_source.addFeatures( new ol.format.GeoJSON().readFeatures(text, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' }) }); I need to convert the EPSG:31983 file for the upload to work.
