📄 losgenerator.java
字号:
} else mark = false; if (LOSprecision == AZIMUTH) { // As of now, this is the // only option range = ((LOSedge * 4) - 4) / (round * 16); for (; x < LOScenterP.x + round; x++) // top resolveImagePoint(x, y, newPixels, azimuthVals, range, pix_arc_interval, mark, markColor); for (; y < LOScenterP.y + round; y++) // right resolveImagePoint(x, y, newPixels, azimuthVals, range, pix_arc_interval, mark, markColor); for (; x > LOScenterP.x - round; x--) // bottom resolveImagePoint(x, y, newPixels, azimuthVals, range, pix_arc_interval, mark, markColor); for (; y > LOScenterP.y - round; y--) // left resolveImagePoint(x, y, newPixels, azimuthVals, range, pix_arc_interval, mark, markColor); } int whereWeAre = (int) (100f * ((float) round / (float) squareRadius)); fireProgressUpdate(ProgressEvent.UPDATE, "Analyzing data...", whereWeAre, 100); } fireProgressUpdate(ProgressEvent.UPDATE, "Creating Mask", 100, 100); LOSimage = new OMRaster(LOScenterLLP.getLatitude(), LOScenterLLP.getLongitude(), (-1 - LOSedge / 2), (-1 - LOSedge / 2), LOSedge, LOSedge, newPixels); LOSimage.generate(proj); graphics.clear(); graphics.add(LOSimage); fireProgressUpdate(ProgressEvent.DONE, "LOS mask complete", 100, 100); if (Debug.debugging("los")) { Debug.output("createLOSimage: Done..."); } } /** * Calculates the color for each pixel. After is gets the slope * value for that pixel, it manages the comparison to get the * pixel colored correctly. */ protected void resolveImagePoint(int x, int y, int[] newPixels, float[] azimuthVals, int range, float pix_arc_interval, boolean mark, int colorForMark) { int ox = LOScenterP.x - LOSedge / 2; int oy = LOScenterP.y - LOSedge / 2; int dist = TerrainLayer.numPixelsBetween(LOScenterP.x, LOScenterP.y, x, y); if (dist > (LOSedge - 1) / 2) { mark = true; colorForMark = INVISIBLE; } if (dist == (LOSedge - 1) / 2) { mark = true; colorForMark = MAYBEVISIBLE; } // This needs to be before the next two lines after this LatLonPoint cord = proj.inverse(x, y); x -= ox; y -= oy; if (Debug.debugging("losdetail")) { Debug.output("resolveImagePoint x = " + x + ", y = " + y); } if (mark == true) { newPixels[x + y * LOSedge] = colorForMark; mark = false; return; } float centerRadLat = LOScenterLLP.radlat_; float centerRadLon = LOScenterLLP.radlon_; float arc_dist = GreatCircle.spherical_distance(centerRadLat, centerRadLon, cord.radlat_, cord.radlon_); float slope = (float) calculateLOSslope(cord, arc_dist); float arc_angle = GreatCircle.spherical_azimuth(centerRadLat, centerRadLon, cord.radlat_, cord.radlon_); int index = Math.round(arc_angle / pix_arc_interval); int maxIndex = (LOSedge * 4) - 4; // 4 corners out for // redundancy if (index < 0) index = maxIndex + index; else if (index >= maxIndex) index = index - maxIndex; if (Debug.debugging("losdetail")) { Debug.output(" angle = " + arc_angle + ", index/maxIndex = " + index + "/" + maxIndex + ", slope = " + slope + " compared to slope[index]=" + azimuthVals[index]); } int color = colortable[INVISIBLE]; if (azimuthVals[index] < slope) { for (int i = (index - range); i < index + range - 1; i++) { if (i < 0) azimuthVals[maxIndex + i] = slope; else if (i >= maxIndex) azimuthVals[i - maxIndex] = slope; else azimuthVals[i] = slope; } color = colortable[VISIBLE]; } if (Debug.debugging("losdetail")) { Debug.output(" color = " + color); } newPixels[x + y * LOSedge] = color; } /** * CalculateLOSslope figures out the slope from the pixel to the * center, in radians. The arc_dist is in radians, and is the * radian arc distance of the point from the center point of the * image, on the earth. This slope calculation does take the * earth's curvature into account, based on the spherical model. */ protected double calculateLOSslope(LatLonPoint cord, float arc_dist) { DTEDFrameCache frameCache = layer.frameCache; if (frameCache == null) { return 0; } int xyheight = frameCache.getElevation(cord.getLatitude(), cord.getLongitude()); double ret = 0; double P = Math.sin(arc_dist) * (xyheight + Planet.wgs84_earthEquatorialRadiusMeters); double xPrime = Math.cos(arc_dist) * (xyheight + Planet.wgs84_earthEquatorialRadiusMeters); double bottom; double cutoff = LOScenterHeight + Planet.wgs84_earthEquatorialRadiusMeters; // Suggested changes, submitted by Mark Wigmore. Introduces // use of doubles, and avoidance of PI/2 tan() calculations. bottom = cutoff - xPrime; ret = MoreMath.HALF_PI_D - Math.atan(bottom / P); return ret; // Old way... // if (xPrime < cutoff) { // bottom = cutoff - xPrime; // ret = Math.atan(P/bottom); // } else if (xPrime == cutoff) { // ret = MoreMath.HALF_PI_D; // } else if (xPrime > cutoff) { // double C = xPrime - cutoff; // double gamma = Math.atan(P/C); // ret = Math.PI - gamma; // } // return ret; } /** * Called when the circle is started. It starts the circle to be * drawn, and sets the parameters that will be needed to figure * out the image. * * @param event mouse event where the circle should be started. */ public void setCenter(MouseEvent event) { graphics.clear(); LOScenterP.x = event.getX(); LOScenterP.y = event.getY(); LOScenterLLP = proj.inverse(LOScenterP.x, LOScenterP.y); LOScenterHeight = LOSobjectHeight; if (layer.frameCache != null) { LOScenterHeight += layer.frameCache.getElevation(LOScenterLLP.getLatitude(), LOScenterLLP.getLongitude()); } LOScirc.setLatLon(LOScenterLLP.getLatitude(), LOScenterLLP.getLongitude()); LOScirc.generate(proj); graphics.add(LOScirc); } /** * Used to modify the circle parameters with another mouse event. * Takes care of resetting hte circle parameters and regenerating * the circle. */ public void addLOSEvent(MouseEvent event) { graphics.clear(); LOSedge = TerrainLayer.numPixelsBetween(LOScenterP.x, LOScenterP.y, event.getX(), event.getY()) * 2 + 1; LOScirc.setWidth(LOSedge); LOScirc.setHeight(LOSedge); LOScirc.generate(proj); graphics.add(LOScirc); } /** * Sets the new object height to use at the center of the circle. * The old object is subtracted out first to get the center height * of the ground before the new value is added. * * @param value height of the object in meters. */ public void setLOSobjectHeight(int value) { LOScenterHeight = LOScenterHeight - LOSobjectHeight; LOSobjectHeight = value; LOScenterHeight = LOScenterHeight + LOSobjectHeight; } /** * Add a ProgressListener that will display build progress. */ public void addProgressListener(ProgressListener list) { progressSupport.addProgressListener(list); } /** * Remove a ProgressListener that displayed build progress. */ public void removeProgressListener(ProgressListener list) { progressSupport.removeProgressListener(list); } /** * Clear all progress listeners. */ public void clearProgressListeners() { progressSupport.removeAll(); } /** * Fire an build update to progress listeners. * * @param frameNumber the current frame count * @param totalFrames the total number of frames. */ protected void fireProgressUpdate(int type, String task, int frameNumber, int totalFrames) { progressSupport.fireUpdate(type, task, totalFrames, frameNumber); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -