@Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl dst = new ProjectionPointImpl(); projectInverse(fromX, fromY, dst); if (dst.getX() < -Math.PI) dst.setX(-Math.PI); else if (dst.getX() > Math.PI) dst.setX(Math.PI); if (projectionLongitude != 0) dst.setX(MapMath.normalizeLongitude(dst.getX() + projectionLongitude)); result.setLongitude(Math.toDegrees(dst.getX())); result.setLatitude(Math.toDegrees(dst.getY())); return result; }
@Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl dst = new ProjectionPointImpl(); projectInverse(fromX, fromY, dst); if (dst.getX() < -Math.PI) dst.setX(-Math.PI); else if (dst.getX() > Math.PI) dst.setX(Math.PI); if (projectionLongitude != 0) dst.setX(MapMath.normalizeLongitude(dst.getX() + projectionLongitude)); result.setLongitude(Math.toDegrees(dst.getX())); result.setLatitude(Math.toDegrees(dst.getY())); return result; }
@Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl dst = new ProjectionPointImpl(); projectInverse(fromX, fromY, dst); if (dst.getX() < -Math.PI) dst.setX(-Math.PI); else if (dst.getX() > Math.PI) dst.setX(Math.PI); if (projectionLongitude != 0) dst.setX(MapMath.normalizeLongitude(dst.getX()) + projectionLongitude); result.setLongitude(Math.toDegrees(dst.getX())); result.setLatitude(Math.toDegrees(dst.getY())); return result; }
@Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl dst = new ProjectionPointImpl(); projectInverse(fromX, fromY, dst); if (dst.getX() < -Math.PI) dst.setX(-Math.PI); else if (dst.getX() > Math.PI) dst.setX(Math.PI); if (projectionLongitude != 0) dst.setX(MapMath.normalizeLongitude(dst.getX()) + projectionLongitude); result.setLongitude(Math.toDegrees(dst.getX())); result.setLatitude(Math.toDegrees(dst.getY())); return result; }
break; xy.setX(xy.getX() * sinlam);
/** * Convert projection coordinates to a LatLonPoint * Note: a new object is not created on each call for the return value. * * @param world convert from these projection coordinates * @param result the object to write to * @return LatLonPoint convert to these lat/lon coordinates */ @Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl pp = new ProjectionPointImpl(); projectInverse(fromX, fromY, pp); if (pp.getX() < -Math.PI) { pp.setX(-Math.PI); } else if (pp.getX() > Math.PI) { pp.setX(Math.PI); } if (projectionLongitude != 0 && !Double.isNaN(pp.getX())) { pp.setX(MapMath.normalizeLongitude(pp.getX() + projectionLongitude)); } result.setLatitude( Math.toDegrees(pp.getY())); result.setLongitude( Math.toDegrees(pp.getX())); return result; }
/** * Convert projection coordinates to a LatLonPoint * Note: a new object is not created on each call for the return value. * * @param world convert from these projection coordinates * @param result the object to write to * @return LatLonPoint convert to these lat/lon coordinates */ @Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl pp = new ProjectionPointImpl(); projectInverse(fromX, fromY, pp); if (pp.getX() < -Math.PI) { pp.setX(-Math.PI); } else if (pp.getX() > Math.PI) { pp.setX(Math.PI); } if (projectionLongitude != 0 && !Double.isNaN(pp.getX())) { pp.setX(MapMath.normalizeLongitude(pp.getX() + projectionLongitude)); } result.setLatitude( Math.toDegrees(pp.getY())); result.setLongitude( Math.toDegrees(pp.getX())); return result; }
break; xy.setX(xy.getX() * sinlam);
public static int intersectSegments(ProjectionPoint aStart, ProjectionPoint aEnd, ProjectionPoint bStart, ProjectionPoint bEnd, ProjectionPointImpl p) { double a1, a2, b1, b2, c1, c2; double r1, r2, r3, r4; double denom, offset, num; a1 = aEnd.getY()-aStart.getY(); b1 = aStart.getX()-aEnd.getX(); c1 = aEnd.getX()*aStart.getY() - aStart.getX()*aEnd.getY(); r3 = a1*bStart.getX() + b1*bStart.getY() + c1; r4 = a1*bEnd.getX() + b1*bEnd.getY() + c1; if (r3 != 0 && r4 != 0 && sameSigns(r3, r4)) return DONT_INTERSECT; a2 = bEnd.getY()-bStart.getY(); b2 = bStart.getX()-bEnd.getX(); c2 = bEnd.getX()*bStart.getY()-bStart.getX()*bEnd.getY(); r1 = a2*aStart.getX() + b2*aStart.getY() + c2; r2 = a2*aEnd.getX() + b2*aEnd.getY() + c2; if (r1 != 0 && r2 != 0 && sameSigns(r1, r2)) return DONT_INTERSECT; denom = a1*b2 - a2*b1; if (denom == 0) return COLLINEAR; offset = denom < 0 ? -denom/2 : denom/2; num = b1*c2 - b2*c1; p.setX((num < 0 ? num-offset : num+offset) / denom); num = a2*c1 - a1*c2; p.setY((num < 0 ? num-offset : num+offset) / denom); return DO_INTERSECT; }
public static int intersectSegments(ProjectionPoint aStart, ProjectionPoint aEnd, ProjectionPoint bStart, ProjectionPoint bEnd, ProjectionPointImpl p) { double a1, a2, b1, b2, c1, c2; double r1, r2, r3, r4; double denom, offset, num; a1 = aEnd.getY()-aStart.getY(); b1 = aStart.getX()-aEnd.getX(); c1 = aEnd.getX()*aStart.getY() - aStart.getX()*aEnd.getY(); r3 = a1*bStart.getX() + b1*bStart.getY() + c1; r4 = a1*bEnd.getX() + b1*bEnd.getY() + c1; if (r3 != 0 && r4 != 0 && sameSigns(r3, r4)) return DONT_INTERSECT; a2 = bEnd.getY()-bStart.getY(); b2 = bStart.getX()-bEnd.getX(); c2 = bEnd.getX()*bStart.getY()-bStart.getX()*bEnd.getY(); r1 = a2*aStart.getX() + b2*aStart.getY() + c2; r2 = a2*aEnd.getX() + b2*aEnd.getY() + c2; if (r1 != 0 && r2 != 0 && sameSigns(r1, r2)) return DONT_INTERSECT; denom = a1*b2 - a2*b1; if (denom == 0) return COLLINEAR; offset = denom < 0 ? -denom/2 : denom/2; num = b1*c2 - b2*c1; p.setX((num < 0 ? num-offset : num+offset) / denom); num = a2*c1 - a1*c2; p.setY((num < 0 ? num-offset : num+offset) / denom); return DO_INTERSECT; }