Sorry, I forgot to mention I am using Oracle JDK 7. I mention this because I 
noticed the Crop.java class has been changed due to issues with OpenJDK. Maybe 
there are issues with this area because of Oracle JDK?

Best Regards,-Tony
 

    On Sunday, February 14, 2016 9:14 PM, Tony Anecito <[email protected]> 
wrote:
 

 Hi All,
Basically I am reading a geotiff file via geoserver and in turn cropping (the 
scaling) a region of interest. The problem is the area I am getting back from 
crop is 1x1 pixel.

I am using crop in Crop.java (geoserver 2.8.2 with the geotools provided with 
it) and I am getting back results I do not expect. Below I list the functions 
with what I know about input/output to hopefully determine what the issue is 
and hopefully recommendations to fix.

//from geoserver passed onto extension?
final GridCoverage2D coverage = coverageReader.read(CoverageUtils.getParameters(
                    coverageReader.getFormat().getReadParameters(), parameters, 
true));
param.parameter("Source").setValue(coverage); //source in Crop.doOperation()

Crop.doOperation() 
-------------------------------------------------------------------------------------------------------------------
source = (GridCoverage2D) sourceParameter.getValue();
final AffineTransform sourceCornerGridToWorld = (AffineTransform) 
((GridGeometry2D) source
                        .getGridGeometry())
                        .getGridToCRS(PixelInCell.CELL_CORNER);

The intersectionEnvelope has : lower corner of -140, -10 and upper corner of 
-120,10 



Crop.BuildResults() 
-----------------------------------------------------------------------------------------------------------------The
 cropEnvelope created inside crop has Min/Max x,y values for: 
lower corner: -140, -10 and the upper corner -120, 10
The sourceWorldToGridTransform is the inverse transform of 
sourceGridToWorldTransform which is the sourceCornerGridToWorld transform.
The cropEnvelope above are the values just before:final Rectangle2D 
finalRasterAreaDouble = XAffineTransform
                    .transform(sourceWorldToGridTransform,
                            cropEnvelope.toRectangle2D(), null);
The finalRasterAreaDouble are 23040,11520 and 23041, 115201 

// intersection with the original range in order to not try to crop
            // outside the image bounds
            Rectangle.intersect(finalRasterArea, sourceGridRange,
                    finalRasterArea);
The finalRasterAreaDouble is still after the above Rectangle.intersect 
23040,11520 and 23041, 115201 
internalROI is null

At the end of Build Results method inside Crop.java:
I am getting back a coverage of width 1 and height 1. The minx and min y are 
23040 and 11520 respectively. 


Any ideas? I am suspecting something wrong about the first transform when you 
get into BuildResults(). Why would the resultant rectangle be in the middle of 
the image and one pixel apart for the final raster area?
Best Regards,-Tony





  
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to