7

In my GIS application the data are sometimes stored in "Google Mercator" (in meters), sometimes in WGS84 LatLon. I'd like a reliable library to convert this data easily and in a "scientific" way, rather than messing with it manually, risking big errors.

I've come across Proj4, which apparently is able to do this: http://trac.osgeo.org/proj

but I can't find a similar library for Java (or Groovy). Such a project would be highly beneficial, given that those projections are increasingly common in online applications. A little jar would be amazing :-)

There is a Java port, but there aren't any files to download: http://www.jhlabs.com/java/maps/proj/

Basically I need to do this type of conversion: http://proj4js.org

Any idea about how to do this in Java?

Thanks, Mulone

Mulone
  • 3,603
  • 9
  • 47
  • 69
  • on the same page the author mentions the new location of the Java port: http://sourceforge.net/projects/jmapprojlib/ – Andreas Dolk Jan 21 '11 at 13:20

3 Answers3

5

Have a look at GeoTools. The bad thing is you don't get a little jar, but about a hundred.

This Tutorial might show something similiar to what you want to accomplish.

adrianboimvaser
  • 2,651
  • 1
  • 22
  • 30
0

I would also recommend GeoTools: look at the CRS class:

http://docs.geotools.org/latest/userguide/library/referencing/crs.html

Using Maven:

    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-api</artifactId>
      <version>8-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-referencing</artifactId>
        <version>8-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>8-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-extension</artifactId>
        <version>${version.geotools}</version>
    </dependency>

The gt-epsg-hsql basically included a HSQL database with a load of CRS definitions already loaded. However, you can also manually load definitions using WKT:

CRS.parseWKT( txt )

This means you can pop on over to http://spatialreference.org/, grab an OGC WKT definition and plumb it in.

Also, Proj4 does have JNI bindings if you fancy going that route.

0

Java port by JH Labs, now maintained by the Cartography and Geovisualization Group, Oregon State University is now on GitHub: https://github.com/OSUCartography/JMapProjLib

Jake
  • 951
  • 8
  • 24
Cezariusz
  • 463
  • 8
  • 15