/** * look through the list of coordinate, and see if any are contained within the currently visible * area */ private boolean isVisible( final LatLonPoint tl, final LatLonPoint br, final CoordFloatString coords) { boolean res = false; final MWC.GenericData.WorldLocation _tl = new MWC.GenericData.WorldLocation(tl.getLatitude(), tl.getLongitude(), 0); final MWC.GenericData.WorldLocation _br = new MWC.GenericData.WorldLocation(br.getLatitude(), br.getLongitude(), 0); final MWC.GenericData.WorldArea area = new MWC.GenericData.WorldArea(_tl, _br); area.normalise(); for (int i = 0; i < coords.maxIndex(); i++) { final float x = coords.getXasFloat(i); final float y = coords.getYasFloat(i); _workingLocation.setLat(y); _workingLocation.setLong(x); if (area.contains(_workingLocation)) { res = true; continue; } } return res; }
private boolean overlaps( final LatLonPoint tl, final LatLonPoint br, final CoordFloatString coords) { boolean res = false; float maxLat = 0, minLat = 0, maxLong = 0, minLong = 0; boolean first = true; // create our area of interest _workingArea.getTopLeft().setLat(tl.getLatitude()); _workingArea.getTopLeft().setLong(tl.getLongitude()); _workingArea.getBottomRight().setLat(br.getLatitude()); _workingArea.getBottomRight().setLong(br.getLongitude()); // build up the area of the coords final int len = Math.abs(coords.maxIndex()); for (int i = 0; i < len; i++) { // retrieve the x and y values final float x = coords.getXasFloat(i); final float y = coords.getYasFloat(i); // initialise our values if this is the first pass if (first) { first = false; maxLat = minLat = y; maxLong = minLong = x; } else { // else update our extreme values minLat = Math.min(minLat, y); maxLat = Math.max(maxLat, y); minLong = Math.min(minLong, x); maxLong = Math.max(maxLong, x); } } // put our limits into the area of this line _otherWorkingArea.getTopLeft().setLat(maxLat); _otherWorkingArea.getTopLeft().setLong(minLong); _otherWorkingArea.getBottomRight().setLat(minLat); _otherWorkingArea.getBottomRight().setLong(maxLong); // so, we've now got our two areas, see if they overlap res = _workingArea.overlaps(_otherWorkingArea); // well done! return res; }
/** method to convert multiple polylines into a single area */ @SuppressWarnings("rawtypes") private java.awt.Polygon extendArea( final Vector ipts, final int totalSize, final LatLonPoint ll1, final LatLonPoint ll2, final float dpplat, final float dpplon, final boolean doAntarcticaWorkaround, final MWC.Algorithms.PlainProjection proj) { Polygon res = null; int i, j; final int size = ipts.size(); int npts = 0; // create the output arrays final int[] xlpts = new int[totalSize]; final int[] ylpts = new int[totalSize]; boolean antarcticaWorkaround = doAntarcticaWorkaround; // only do it if we're in the vicinity if (antarcticaWorkaround) { antarcticaWorkaround = (ll2.getLatitude() < -62f); } // step through the areas we've been provided for (j = 0; j < size; j++) { final CoordFloatString cfs = (CoordFloatString) ipts.elementAt(j); int cfscnt = cfs.tcount; final int cfssz = cfs.tsize; final float cfsvals[] = cfs.vals; // see if this line is going clockwise or anti-clockwise if (cfscnt > 0) { // normal for (i = 0; i < cfscnt; i++) { _workingLocation.setLat(cfsvals[i * cfssz + 1]); _workingLocation.setLong(cfsvals[i * cfssz]); final java.awt.Point pt = proj.toScreen(_workingLocation); xlpts[npts] = pt.x; ylpts[npts++] = pt.y; // res.addPoint(pt.x, pt.y); } } else { // reverse cfscnt *= -1; for (i = cfscnt - 1; i >= 0; i--) { _workingLocation.setLat(cfsvals[i * cfssz + 1]); _workingLocation.setLong(cfsvals[i * cfssz]); final java.awt.Point pt = proj.toScreen(_workingLocation); xlpts[npts] = pt.x; ylpts[npts++] = pt.y; // res.addPoint(pt.x, pt.y); } } } // pop the data into a polygon (just for tidy storage really) res = new java.awt.Polygon(xlpts, ylpts, npts); return res; }
/** * Convert to a geocentric frame using a LatLonPoint. * * @param llpt * @return a vector of ecef values */ public double[] toGeocentricFrame(LatLonPoint llpt) { // All calculations are done using radians! double ecef[] = new double[3]; double ned[] = new double[3]; double lat_ = (double) llpt.getLatitude(); double lon_ = (double) llpt.getLongitude(); double latitude = ProjMath.degToRad(lat_); double longitude = ProjMath.degToRad(lon_); ned2ecef(ned, latitude, longitude, ecef); return ecef; }
/** * set lat and lon by using UTM coordinates * * @param strZone UTM-zone, e.g. 32U * @param strNorthing Northing component * @param strEasting Easting component */ public void set(String strZone, String strNorthing, String strEasting) { LatLonPoint ll = new LatLonPoint(); utm.zone_letter = strZone.charAt(strZone.length() - 1); utm.zone_number = Convert.toInt(strZone.substring(0, strZone.length() - 1)); utm.northing = (float) Common.parseDouble(strNorthing); utm.easting = (float) Common.parseDouble(strEasting); ll = utm.toLatLonPoint(); // returns null if unvalit UTM-coordinates if (ll != null) { this.utmValid = true; this.latDec = ll.getLatitude(); this.lonDec = ll.getLongitude(); } else { this.latDec = 91; this.lonDec = 361; } }
/** * Construct a NedFrame from a ECEF vector and a LatLonPoint. * * @param ecefVector */ public NedFrame(double[] ecefVector, LatLonPoint llpt) { // All calculations are done using radians! double ecef[] = new double[3]; double ned[] = new double[3]; double lat_ = (double) llpt.getLatitude(); double lon_ = (double) llpt.getLongitude(); double latitude = ProjMath.degToRad(lat_); double longitude = ProjMath.degToRad(lon_); ecef[0] = ecefVector[0]; ecef[1] = ecefVector[1]; ecef[2] = ecefVector[2]; ecef2ned(ned, latitude, longitude, ecef); this.x = (float) ned[0]; this.y = (float) ned[1]; this.z = (float) ned[2]; }
/** * Create CWPoint by using a LatLonPoint * * @param CWPoint LatLonPoint */ public CWPoint(LatLonPoint llPoint) { super(llPoint.getLatitude(), llPoint.getLongitude()); this.utmValid = false; }
/** * Set CWPoint by using a LatLonPoint * * @param CWPoint LatLonPoint */ public void set(LatLonPoint llPoint) { this.latDec = llPoint.getLatitude(); this.lonDec = llPoint.getLongitude(); this.utmValid = false; }
/** * Create a OMEllipse, positioned with a lat-lon center and x-y axis. Rendertype is * RENDERTYPE_OFFSET. * * @param centerPoint latitude/longitude of center point, decimal degrees * @param w horizontal diameter of circle/ellipse, pixels * @param h vertical diameter of circle/ellipse, pixels * @param rotateAngle angle of rotation in Radians */ public OMEllipse(LatLonPoint centerPoint, int w, int h, double rotateAngle) { // Use circle constructor super(centerPoint.getLatitude(), centerPoint.getLongitude(), 0, 0, w, h); setRotationAngle(rotateAngle); }
/** * Create a OMEllipse, positioned at a Lat-lon location, x-y offset, x-y axis. Rendertype is * RENDERTYPE_OFFSET. * * @param centerPoint latitude/longitude of center point, decimal degrees * @param offset_x1 # pixels to the right the center will be moved from lonPoint. * @param offset_y1 # pixels down that the center will be moved from latPoint. * @param w horizontal diameter of circle/ellipse, pixels. * @param h vertical diameter of circle/ellipse, pixels. */ public OMEllipse( LatLonPoint centerPoint, int offset_x1, int offset_y1, int w, int h, double rotateAngle) { super(centerPoint.getLatitude(), centerPoint.getLongitude(), offset_x1, offset_y1, w, h); setRotationAngle(rotateAngle); }