Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for constructing CRS from an OGC URN #23

Open
securedimensions opened this issue Mar 16, 2019 · 1 comment
Open

Support for constructing CRS from an OGC URN #23

securedimensions opened this issue Mar 16, 2019 · 1 comment

Comments

@securedimensions
Copy link

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)
@echeipesh
Copy link
Contributor

echeipesh commented Aug 22, 2019

This project is not able to parse OGC URNs for projections, this would have to be a feature that is added. Indeed only a single version of EPSG database is available at a time.

It looks like the source PROJ project now supports this feature though and it would be a good idea to consider this as part of other upstream ports.

Renaming the issue to better reflect the fact this is a feature request and not a bug.

@echeipesh echeipesh changed the title Unable to access CRS file: proj4/nad/urn Support for constructing CRS from an OGC URN Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants