Transformation von ViennaGIS zu WGS84 Koordinaten
Umwandlung von ViennaGIS Gauß-Krüger M 34 MGI Austria GK East in Google WGS84 Koordinaten unter Verwendung des EPSG-Codes 31256.
Umwandlung von ViennaGIS Gauß-Krüger M 34 MGI Austria GK East in Google WGS84 Koordinaten unter Verwendung des EPSG-Codes 31256.

In einem aktuellen Projekt musste ich die Koordinaten von ViennaGIS Gauß-Krüger M 34 MGI Austria GK East in Google WGS84 unter Verwendung des EPSG-Codes 31256 umwandeln. Der Zweck war das Anzeigen von Pins auf Google Maps oder Leaflet für von ViennaGIS bereitgestellten Objekten und Orten.
Leider verwendet ViennaGIS eine Gauß-Krüger M 34-Projektion, die mit den meisten Map-SDKs nicht verwendet werden kann. Daher musste ich die Koordinaten vorher in das Koordinatensystem von Google umwandeln. Ich habe die Bibliotheken proj4j und proj4js verwendet, die Java und JavaScript-Ports der proj-Bibliothek sind.
Die folgenden Code-Snippets zeigen, wie ViennaGIS GK34 zu WGS84 Koordinaten mit Kotlin bzw. JavaScript transformiert werden können.
Kotlin
Gk34ToWgs84CoordinatesTransformer.kt
// Kotlin version // Maven dependency: // <dependency> // <groupId>org.locationtech.proj4j</groupId> // <artifactId>proj4j</artifactId> // <version>1.0.0</version> // </dependency> package at.agsolutions import at.agsolutions.Gk34Dto import at.agsolutions.Wgs84Dto import org.locationtech.proj4j.CRSFactory import org.locationtech.proj4j.CoordinateTransformFactory import org.locationtech.proj4j.ProjCoordinate class Gk34ToWgs84CoordinatesTransformer { private val coordinateTranformFactory = CoordinateTransformFactory() /** * EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich * Cadastral plan in Eastern Austria (Irenental) * see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria */ private val transformGk34ToWgs84 = coordinateTranformFactory.createTransform( /* GK34 */ CRSFactory().createFromName("epsg:31256"), /* WGS84 */ CRSFactory().createFromName("epsg:4326") ) fun transform(gk34: Gk34Dto): Wgs84Dto { val result = ProjCoordinate() transformGk34ToWgs84.transform(ProjCoordinate(gk34.x.toDouble(), gk34.y.toDouble()), result) return Wgs84Dto(result.y.toBigDecimal(), result.x.toBigDecimal
// Kotlin version // Maven dependency: // <dependency> // <groupId>org.locationtech.proj4j</groupId> // <artifactId>proj4j</artifactId> // <version>1.0.0</version> // </dependency> package at.agsolutions import at.agsolutions.Gk34Dto import at.agsolutions.Wgs84Dto import org.locationtech.proj4j.CRSFactory import org.locationtech.proj4j.CoordinateTransformFactory import org.locationtech.proj4j.ProjCoordinate class Gk34ToWgs84CoordinatesTransformer { private val coordinateTranformFactory = CoordinateTransformFactory() /** * EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich * Cadastral plan in Eastern Austria (Irenental) * see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria */ private val transformGk34ToWgs84 = coordinateTranformFactory.createTransform( /* GK34 */ CRSFactory().createFromName("epsg:31256"), /* WGS84 */ CRSFactory().createFromName("epsg:4326") ) fun transform(gk34: Gk34Dto): Wgs84Dto { val result = ProjCoordinate() transformGk34ToWgs84.transform(ProjCoordinate(gk34.x.toDouble(), gk34.y.toDouble()), result) return Wgs84Dto(result.y.toBigDecimal(), result.x.toBigDecimal
// Kotlin version // Maven dependency: // <dependency> // <groupId>org.locationtech.proj4j</groupId> // <artifactId>proj4j</artifactId> // <version>1.0.0</version> // </dependency> package at.agsolutions import at.agsolutions.Gk34Dto import at.agsolutions.Wgs84Dto import org.locationtech.proj4j.CRSFactory import org.locationtech.proj4j.CoordinateTransformFactory import org.locationtech.proj4j.ProjCoordinate class Gk34ToWgs84CoordinatesTransformer { private val coordinateTranformFactory = CoordinateTransformFactory() /** * EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich * Cadastral plan in Eastern Austria (Irenental) * see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria */ private val transformGk34ToWgs84 = coordinateTranformFactory.createTransform( /* GK34 */ CRSFactory().createFromName("epsg:31256"), /* WGS84 */ CRSFactory().createFromName("epsg:4326") ) fun transform(gk34: Gk34Dto): Wgs84Dto { val result = ProjCoordinate() transformGk34ToWgs84.transform(ProjCoordinate(gk34.x.toDouble(), gk34.y.toDouble()), result) return Wgs84Dto(result.y.toBigDecimal(), result.x.toBigDecimal
JavaScript
index.js
// JS version // package.json contents: // { // "name": "vienna-gis-to-wgs84", // "version": "1.0.0", // "main": "index.js", // "dependencies": { // "epsg": "^0.5.0", // "proj4": "^2.5.0" // } // } const proj4 = require('proj4'); const epsg = require('epsg'); /** * EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich * Cadastral plan in Eastern Austria (Irenental) * see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria */ const gk34ToWgs84 = coordinates => { const result = proj4(epsg['EPSG:31256'], 'WGS84', Object.assign({}, coordinates)); console.log(coordinates.x + ', ' + coordinates.y + ' = ' + result.y + ', ' + result.x); }; gk34ToWgs84({ x: 2950.77, y: 341754.91 }); gk34ToWgs84({ x: 5860.5, y: 342140.71 }); gk34ToWgs84({ x: -9587.52, y: 344411.47 });
// JS version // package.json contents: // { // "name": "vienna-gis-to-wgs84", // "version": "1.0.0", // "main": "index.js", // "dependencies": { // "epsg": "^0.5.0", // "proj4": "^2.5.0" // } // } const proj4 = require('proj4'); const epsg = require('epsg'); /** * EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich * Cadastral plan in Eastern Austria (Irenental) * see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria */ const gk34ToWgs84 = coordinates => { const result = proj4(epsg['EPSG:31256'], 'WGS84', Object.assign({}, coordinates)); console.log(coordinates.x + ', ' + coordinates.y + ' = ' + result.y + ', ' + result.x); }; gk34ToWgs84({ x: 2950.77, y: 341754.91 }); gk34ToWgs84({ x: 5860.5, y: 342140.71 }); gk34ToWgs84({ x: -9587.52, y: 344411.47 });
// JS version // package.json contents: // { // "name": "vienna-gis-to-wgs84", // "version": "1.0.0", // "main": "index.js", // "dependencies": { // "epsg": "^0.5.0", // "proj4": "^2.5.0" // } // } const proj4 = require('proj4'); const epsg = require('epsg'); /** * EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich * Cadastral plan in Eastern Austria (Irenental) * see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria */ const gk34ToWgs84 = coordinates => { const result = proj4(epsg['EPSG:31256'], 'WGS84', Object.assign({}, coordinates)); console.log(coordinates.x + ', ' + coordinates.y + ' = ' + result.y + ', ' + result.x); }; gk34ToWgs84({ x: 2950.77, y: 341754.91 }); gk34ToWgs84({ x: 5860.5, y: 342140.71 }); gk34ToWgs84({ x: -9587.52, y: 344411.47 });
Weitere Beiträge zum Thema


