locationtech / locationtech/proj4j

Support for constructing CRS from an OGC URN

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
232
Forks
86
PR merge metrics
No merged PRs in 30d

Description

The recognition of CRS identifiers starting with "urn:" fail. What do I need to do to get support for URN based CRS identifiers?

This example program - using proj4j from maven (org.locationtech.proj4j / proj4j / 1.0.0) - illustrates the problem for use of CRS = urn:ogc:def:crs:EPSG::4326:

import org.locationtech.proj4j.CRSFactory;
import org.locationtech.proj4j.CoordinateReferenceSystem;
import org.locationtech.proj4j.CoordinateTransform;
import org.locationtech.proj4j.CoordinateTransformFactory;
import org.locationtech.proj4j.ProjCoordinate;

public class Test {

	public static void main(String[] args) {

		testExplicitTransform();
		
	}
	
	   public static void testExplicitTransform() {
	        String csName1 = "EPSG:32636";
	        String csName2 = "urn:ogc:def:crs:EPSG::4326";

	        CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
	        CRSFactory csFactory = new CRSFactory();

	        CoordinateReferenceSystem crs1 = csFactory.createFromName(csName1);
	        CoordinateReferenceSystem crs2 = csFactory.createFromName(csName2);

	        System.out.println(csName1 + " unit: " + crs1.getProjection().getUnits());
	        System.out.println(csName2 + " unit: " + crs2.getProjection().getUnits());
	        
	        CoordinateTransform trans = ctFactory.createTransform(crs1, crs2);
	    
	        ProjCoordinate p1 = new ProjCoordinate();
	        ProjCoordinate p2 = new ProjCoordinate();
	        p1.x = 500000;
	        p1.y = 4649776.22482;
	    
	        /*
	         * Transform point
	         */
	        ProjCoordinate px = trans.transform(p1, p2);
	        System.out.println(px.toString());
	}

}

The program ends with this exception:

Exception in thread "main" java.lang.IllegalStateException: Unable to access CRS file: proj4/nad/urn
	at org.locationtech.proj4j.io.Proj4FileReader.readParametersFromFile(Proj4FileReader.java:41)
	at org.locationtech.proj4j.io.Proj4FileReader.getParameters(Proj4FileReader.java:151)
	at org.locationtech.proj4j.CRSFactory.createFromName(CRSFactory.java:82)
	at de.securedimensions.crs.Test.testExplicitTransform(Test.java:25)
	at de.securedimensions.crs.Test.main(Test.java:13)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CRSFactory.createFromName and the failing path through Proj4FileReader.java shown in the stack trace. Run the supplied Test program with urn:ogc:def:crs:EPSG::4326 and verify that CRS creation and the coordinate transform complete without the proj4/nad/urn access error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.