Revision: 5958
http://sourceforge.net/p/jump-pilot/code/5958
Author: ma15569
Date: 2018-10-04 08:44:30 +0000 (Thu, 04 Oct 2018)
Log Message:
-----------
a) Correction on compute hillshade according ESRI definition
(http://edndoc.esri.com/arcobjects/9.2/net/shared/geoprocessing/spatial_analyst_tools/how_hillshade_works.htm)
b) add missing class on histogram algorithms
Modified Paths:
--------------
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/hillshade/HillshadeStripe.java
Added Paths:
-----------
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/rastertools/classifiers/GivenIntervals.java
Modified:
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/hillshade/HillshadeStripe.java
===================================================================
---
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/hillshade/HillshadeStripe.java
2018-09-25 20:14:49 UTC (rev 5957)
+++
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/hillshade/HillshadeStripe.java
2018-10-04 08:44:30 UTC (rev 5958)
@@ -2,6 +2,7 @@
import com.geomaticaeambiente.openjump.klem.grid.DoubleBasicGrid;
import com.geomaticaeambiente.openjump.klem.parallel.Shifter;
+
import java.io.IOException;
import java.util.concurrent.Callable;
@@ -50,10 +51,33 @@
double slopeRad =
Math.toRadians(slopeDegsGrid.getValue(col, row));
double aspectRad =
Math.toRadians(aspectDegsGrid.getValue(col, row));
- double hillshade = 255.0 *
- ((Math.cos(zenithRad) * Math.cos(slopeRad)) +
- (Math.sin(zenithRad) * Math.sin(slopeRad) *
Math.cos(azimuthRad - aspectRad)));
- hillshadeGrid.setValue(col, row,
Math.toDegrees(hillshade));
+ double aspectRad2;
+ /*
+ * [Giuseppe Aruta =ct 4 2018] correctios from:
+ * http://edndoc.esri.com/arcobjects/9.2/net/shared/
+ * geoprocessing
+ * /spatial_analyst_tools/how_hillshade_works.htm
+ */
+ //
+ if (aspectRad < 0) {
+ aspectRad2 = 2 * Math.PI + aspectRad;
+ } else {
+ aspectRad2 = aspectRad;
+ }
+
+ final double hillshade = 255.0 * ((Math.cos(zenithRad) *
Math
+ .cos(slopeRad)) + (Math.sin(zenithRad)
+ * Math.sin(slopeRad) * Math.cos(azimuthRad
+ - aspectRad2)));
+ long hillshade2;
+ if (hillshade < 0) {
+ hillshade2 = 0;
+ } else {
+ hillshade2 = Math.round(hillshade);
+ }
+ // hillshadeGrid.setValue(col, row,
+ // Math.toDegrees(hillshade));
+ hillshadeGrid.setValue(col, row, hillshade2);
}
}
}
Added:
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/rastertools/classifiers/GivenIntervals.java
===================================================================
---
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/rastertools/classifiers/GivenIntervals.java
(rev 0)
+++
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/rastertools/classifiers/GivenIntervals.java
2018-10-04 08:44:30 UTC (rev 5958)
@@ -0,0 +1,63 @@
+package com.geomaticaeambiente.openjump.klem.rastertools.classifiers;
+
+import com.geomaticaeambiente.openjump.klem.grid.DoubleBasicGrid;
+
+public class GivenIntervals implements ClassAlgo {
+ public final DoubleBasicGrid grid;
+ public double interval;
+ public final Double baseVal;
+
+ public GivenIntervals(DoubleBasicGrid grid, double interval, Double base) {
+ this.grid = grid;
+ this.interval = interval;
+ baseVal = base;
+ }
+
+ @Override
+ public double[] getBreakValues() {
+ double minVal = Double.MAX_VALUE;
+ double maxVal = -4.9E-324D;
+ for (int r = 0; r < grid.getRowCount(); r++) {
+ for (int c = 0; c < grid.getColumnCount(); c++) {
+ final double value = grid.getValue(c, r);
+ if (!grid.isNoData(value)) {
+ if (value < minVal) {
+ minVal = value;
+ }
+ if (value > maxVal) {
+ maxVal = value;
+ }
+ }
+ }
+ }
+ int intvCount = (int) ((maxVal - minVal) / interval);
+ if (intvCount > 100) {
+ intvCount = 100;
+ interval = ((maxVal - minVal) / 100.0D);
+ }
+ if (baseVal != null) {
+ if (baseVal.doubleValue() == 0.0D) {
+ minVal = (int) (minVal / interval) * interval;
+ }
+ if ((baseVal.doubleValue() > 0.0D) && (minVal > 0.0D)) {
+ minVal = (int) (minVal / baseVal.doubleValue())
+ * baseVal.doubleValue();
+ } else if ((baseVal.doubleValue() < 0.0D) && (minVal < 0.0D)) {
+ minVal = (int) (baseVal.doubleValue() / minVal)
+ * baseVal.doubleValue();
+ } else if ((baseVal.doubleValue() < 0.0D) && (minVal > 0.0D)) {
+ minVal = (int) (Math.abs(minVal) / Math.abs(baseVal
+ .doubleValue())) * Math.abs(baseVal.doubleValue());
+ }
+ }
+ double endVal = minVal;
+
+ final double[] breaks = new double[intvCount];
+ for (int i = 0; i < intvCount; i++) {
+ final double startVal = endVal;
+ endVal = startVal + interval;
+ breaks[i] = endVal;
+ }
+ return breaks;
+ }
+}
Property changes on:
plug-ins/OpenKLEM/OpenKLEMCore/trunk/src/com/geomaticaeambiente/openjump/klem/rastertools/classifiers/GivenIntervals.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel