Created
October 5, 2018 07:10
-
-
Save ogavrisevs/d9db6383347ab51242bdd31cb24a9702 to your computer and use it in GitHub Desktop.
Convert "EPSG:3059" (LKS-92 TM) to "EPSG:4326" (lat/lng)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bla.laa; | |
import org.geotools.geometry.jts.JTS; | |
import org.geotools.referencing.CRS; | |
import org.geotools.referencing.GeodeticCalculator; | |
import org.locationtech.jts.geom.Coordinate; | |
import org.opengis.referencing.FactoryException; | |
import org.opengis.referencing.NoSuchAuthorityCodeException; | |
import org.opengis.referencing.crs.CoordinateReferenceSystem; | |
import org.opengis.referencing.operation.MathTransform; | |
import org.opengis.referencing.operation.TransformException; | |
public class Main2 { | |
public static void main(String[] args) throws NoSuchAuthorityCodeException, FactoryException, TransformException { | |
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326"); | |
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:3059"); | |
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); | |
Coordinate coordinate = new Coordinate(312424.0,512414.0); | |
Coordinate targetCoordinate = JTS.transform( coordinate, null, transform ); | |
System.out.println(targetCoordinate.getX() +" , "+ targetCoordinate.getY()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.mycompany.app</groupId> | |
<artifactId>my-app</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>Maven Quick Start Archetype</name> | |
<url>http://maven.apache.org</url> | |
<repositories> | |
<repository> | |
<id>maven2-repository.dev.java.net</id> | |
<name>Java.net repository</name> | |
<url>http://download.java.net/maven/2</url> | |
</repository> | |
<repository> | |
<id>osgeo</id> | |
<name>Open Source Geospatial Foundation Repository</name> | |
<url>http://download.osgeo.org/webdav/geotools/</url> | |
</repository> | |
<repository> | |
<snapshots> | |
<enabled>true</enabled> | |
</snapshots> | |
<id>boundless</id> | |
<name>Boundless Maven Repository</name> | |
<url>http://repo.boundlessgeo.com/main</url> | |
</repository> | |
</repositories> | |
<dependencies> | |
<dependency> | |
<groupId>org.geotools</groupId> | |
<artifactId>gt-main</artifactId> | |
<version>20.0</version> | |
</dependency> | |
<dependency> | |
<groupId>org.geotools</groupId> | |
<artifactId>gt-epsg-hsql</artifactId> | |
<version>20.0</version> | |
</dependency> | |
<dependency> | |
<groupId>org.geotools</groupId> | |
<artifactId>gt-referencing</artifactId> | |
<version>20.0</version> | |
<type>jar</type> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment