Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. proj4.defs("EPSG:32633", "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs");
  2. proj4.defs('WGS84', "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
  3. ...
  4. nodes.forEach(n => {
  5. var position = n.position;
  6. n.position = proj4('EPSG:32633', 'WGS84', position);
  7. });
  8.  
  9. private static final CoordinateTransform transfGPS;
  10.  
  11. static {
  12. final CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
  13. final CRSFactory crsFactory = new CRSFactory();
  14. final CoordinateReferenceSystem projWGS84 =
  15. crsFactory.createFromParameters("WGS84",
  16. "+title=long/lat:WGS84 +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
  17. final CoordinateReferenceSystem projEPSG32633 =
  18. crsFactory.createFromParameters("EPSG:32633",
  19. "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs");
  20.  
  21. transfGPS = ctFactory.createTransform(projWGS84, projEPSG32633);
  22. }
  23.  
  24. public static Point epanetToGps(Point position) {
  25. ProjCoordinate p1 = new ProjCoordinate();
  26. ProjCoordinate p2 = new ProjCoordinate();
  27. p1.x = position.getX();
  28. p1.y = position.getY();
  29.  
  30. transfGPS.transform(p1, p2);
  31. return new Point(p2.x, p2.y);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement