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

Javascript conversion help #16

Open
xjpmauricio opened this issue Aug 13, 2020 · 1 comment
Open

Javascript conversion help #16

xjpmauricio opened this issue Aug 13, 2020 · 1 comment

Comments

@xjpmauricio
Copy link

How can I convert this javascript to this java library?

var latitude = 37.42342342342342, longitude = -122.08395287867832;

proj4.defs('EPSG:4326', "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84 +units=degrees");
proj4.defs('EPSG:20790', '+title=Hayford-Gauss Datum Lisboa (Militar) +proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1 +x_0=200000 +y_0=300000 +ellps=intl +towgs84=-283.088,-70.693,117.445,-1.157,0.059,-0.652,-4,058 +pm=lisbon +units=m +no_defs');

var latlng = [latitude,longitude];
var pointDest = proj4('EPSG:20790', 'EPSG:4326', latlng);
var coord = { long: pointDest[0], lat: pointDest[1] };

I've tried using the method factory.createFromParameters but I get all sorts of errors related with the parameters.

Any ideias?

@xjpmauricio
Copy link
Author

I've tried this but I get all sorts of errors:

double latitude = 37.42342342342342, longitude = -122.08395287867832;
CRSFactory factory = new CRSFactory();
CoordinateReferenceSystem sourceCRS = factory.createFromParameters("EPSG:4326",
		"+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84 +units=degrees\"");
CoordinateReferenceSystem targetCRS = factory.createFromParameters("EPSG:20790",
		"+title=Hayford-Gauss Datum Lisboa (Militar) +proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1 +x_0=200000 +y_0=300000 +ellps=intl +towgs84=-283.088,-70.693,117.445,-1.157,0.059,-0.652,-4,058 +pm=lisbon +units=m +no_defs");
CoordinateTransform transform = new CoordinateTransformFactory().createTransform(sourceCRS, targetCRS);
ProjCoordinate srcCoord = new ProjCoordinate(latitude, longitude);
ProjCoordinate destCoord = new ProjCoordinate();
transform.transform(srcCoord, destCoord);

Errors:

org.osgeo.proj4j.UnsupportedParameterException: Datum parameter is not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant