Snippets

Piotr Szrajber Smart M.App - transform feature collection from crs1 to crs2

Created by Piotr Szrajber
function reproject(features, src, dest, callback) {
    mainContext.webgisCore.crsManager.getCRSes([src, dest]).then(function(ref) {
        var crs1 = ref[0],
            crs2 = ref[1];
        var internal = mainContext.geoJsonToInternalTranslator(features, crs1);
        debugger;
        var result = mainContext.internalToGeoJsonTranslator(internal.map(function(g) {
            var transformed = mainContext.webgisCore.coordinatesTransformer.transformGeometrySync(g, crs2)
            return transformed;
        })).map(function(f) {
            delete f.crs;
            return f;
        });
        callback(result);
    });
}

reproject(fc.features, "EPSG:2180", "EPSG:4326", function(result) {
    copy((JSON.stringify({
        type: "FeatureCollection",
        features: result
    })));
})

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.