Re: [JPP-Devel] SVN: [6461] core/trunk/src/org/openjump/core/rasterimage

2020-09-14 Thread Giuseppe Aruta
I reverted the changes. I didn't find a valid way.

Il giorno lun 14 set 2020 alle ore 11:49 Giuseppe Aruta <
giuseppe.ar...@gmail.com> ha scritto:

> Hi Ede,
> can you check if this modification fits memory problems?
> a) On loading TIF (RasterImageIO and TiFFUtils class) I get the envelope
> directly tiff metadata
> b) on the other tools I reuse the previous method
>
> Il giorno lun 14 set 2020 alle ore 10:49  ha scritto:
>
>> Peppe,
>>
>> i noticed earlier that your image reading implementation creates a new
>> Reader on every render call but thought you will notice when this becomes a
>> performance issue.
>>
>> seeing you continue this trend with code like below i become a little
>> worried ;) and suggest you try to model your approach using class instances
>> keeping the reference to be reused hence saving additional file access.
>> easiest would be a "caching" holding the ReferencedImageReader object in a
>> HashMap with the path value as key. remember to close it properly if the
>> layer is removed!
>>
>> this also may become a memory issue as i am not sure that all file
>> handles are closed automatically this way. ..sunshine ede
>>
>>
>> On 9/14/2020 9:51, jump-pilot-svn--- via Jump-pilot-devel wrote:
>> > + /**
>> > +  * Get Envelope  from file
>> > +  * @param fileName
>> > +  * @return Envelope
>> > +  * @throws ReferencedImageException
>> > +  */
>> > +
>> > + public static Envelope getGeoReferencing(String fileName) throws
>> ReferencedImageException {
>> > + GeoReferencedRaster geoRaster = new
>> GeoReferencedRaster(new File(fileName).toURI().toString());
>> > + return geoRaster.getEnvelope();
>> > +
>>
>>
>>
>> ___
>> Jump-pilot-devel mailing list
>> Jump-pilot-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>
>
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] SVN: [6461] core/trunk/src/org/openjump/core/rasterimage

2020-09-14 Thread Giuseppe Aruta
Hi Ede,
can you check if this modification fits memory problems?
a) On loading TIF (RasterImageIO and TiFFUtils class) I get the envelope
directly tiff metadata
b) on the other tools I reuse the previous method

Il giorno lun 14 set 2020 alle ore 10:49  ha scritto:

> Peppe,
>
> i noticed earlier that your image reading implementation creates a new
> Reader on every render call but thought you will notice when this becomes a
> performance issue.
>
> seeing you continue this trend with code like below i become a little
> worried ;) and suggest you try to model your approach using class instances
> keeping the reference to be reused hence saving additional file access.
> easiest would be a "caching" holding the ReferencedImageReader object in a
> HashMap with the path value as key. remember to close it properly if the
> layer is removed!
>
> this also may become a memory issue as i am not sure that all file handles
> are closed automatically this way. ..sunshine ede
>
>
> On 9/14/2020 9:51, jump-pilot-svn--- via Jump-pilot-devel wrote:
> > + /**
> > +  * Get Envelope  from file
> > +  * @param fileName
> > +  * @return Envelope
> > +  * @throws ReferencedImageException
> > +  */
> > +
> > + public static Envelope getGeoReferencing(String fileName) throws
> ReferencedImageException {
> > + GeoReferencedRaster geoRaster = new
> GeoReferencedRaster(new File(fileName).toURI().toString());
> > + return geoRaster.getEnvelope();
> > +
>
>
>
> ___
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] SVN: [6461] core/trunk/src/org/openjump/core/rasterimage

2020-09-14 Thread edgar . soldin
Peppe,

i noticed earlier that your image reading implementation creates a new Reader 
on every render call but thought you will notice when this becomes a 
performance issue.

seeing you continue this trend with code like below i become a little worried 
;) and suggest you try to model your approach using class instances keeping the 
reference to be reused hence saving additional file access. easiest would be a 
"caching" holding the ReferencedImageReader object in a HashMap with the path 
value as key. remember to close it properly if the layer is removed!

this also may become a memory issue as i am not sure that all file handles are 
closed automatically this way. ..sunshine ede


On 9/14/2020 9:51, jump-pilot-svn--- via Jump-pilot-devel wrote:
> + /**
> +  * Get Envelope  from file
> +  * @param fileName
> +  * @return Envelope
> +  * @throws ReferencedImageException
> +  */
> +
> + public static Envelope getGeoReferencing(String fileName) throws 
> ReferencedImageException {
> + GeoReferencedRaster geoRaster = new  
> GeoReferencedRaster(new File(fileName).toURI().toString());
> + return geoRaster.getEnvelope();
> +



___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


[JPP-Devel] SVN: [6461] core/trunk/src/org/openjump/core/rasterimage

2020-09-14 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6461
  http://sourceforge.net/p/jump-pilot/code/6461
Author:   ma15569
Date: 2020-09-14 07:51:37 + (Mon, 14 Sep 2020)
Log Message:
---
Chenged method to get Envelope directly form GeoRasterImage. This solves the 
bug about the right dimension of AsterDEM noted by Michael

Modified Paths:
--
core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
core/trunk/src/org/openjump/core/rasterimage/RasterImageIOUtils.java
core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java

Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
===
--- core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java 
2020-09-13 18:28:24 UTC (rev 6460)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java 
2020-09-14 07:51:37 UTC (rev 6461)
@@ -117,9 +117,9 @@
}
 
}
-
-   Envelope envelope = getGeoReferencing(fileNameOrURL, 
true,
-   new Point(bImage.getWidth(), 
bImage.getHeight()));
+   Envelope envelope = getGeoReferencing(fileNameOrURL);
+   //Envelope envelope = getGeoReferencing(fileNameOrURL, 
true,
+   //  new Point(bImage.getWidth(), 
bImage.getHeight()));
double cellSize = (envelope.getMaxX() - 
envelope.getMinX())
/ bImage.getWidth();
return new ImageAndMetadata(bImage, new 
Metadata(envelope,
@@ -136,8 +136,9 @@
int imgWidth = tiffMetadata.getColsCount();
int imgHeight = tiffMetadata.getRowsCount();
 
-   Envelope imageEnvelope = 
getGeoReferencing(fileNameOrURL, true,
-   new Point(imgWidth, imgHeight));
+   Envelope imageEnvelope = 
getGeoReferencing(fileNameOrURL);
+   //  Envelope imageEnvelope = 
getGeoReferencing(fileNameOrURL, true,
+   //  new Point(imgWidth, imgHeight));
 
Overviews overviews = OverviewsUtils.getOverviews(new 
File(
fileNameOrURL), imageEnvelope);
@@ -296,9 +297,9 @@
Coordinate coordinate, int band) throws Exception {
 
Point imageDims = getImageDimensions(fileNameOrURL);
-
-   Envelope envelope = getGeoReferencing(fileNameOrURL, true, new 
Point(
-   imageDims.x, imageDims.y));
+   Envelope envelope = getGeoReferencing(fileNameOrURL);
+   //Envelope envelope = getGeoReferencing(fileNameOrURL, true, 
new Point(
+   //  imageDims.x, imageDims.y));
double cellSizeX = (envelope.getMaxX() - envelope.getMinX())
/ imageDims.x;
double cellSizeY = (envelope.getMaxY() - envelope.getMinY())
@@ -414,6 +415,30 @@
return null;
}
 
+   /**
+* Get Envelope  from file 
+* @param fileName
+* @return Envelope
+* @throws ReferencedImageException
+*/
+   
+   public static Envelope getGeoReferencing(String fileName) throws 
ReferencedImageException {
+   GeoReferencedRaster geoRaster = new  
GeoReferencedRaster(new File(fileName).toURI().toString());
+   return geoRaster.getEnvelope();
+   
+   }
+   
+   /**
+* Substituted by method getGeoReferencing(String fileName)
+* @deprecated
+* @param fileName
+* @param allwaysLookForTFWExtension
+* @param imageDimensions
+* @return Envelope
+* @throws Exception
+*/
+   
+   @Deprecated
public static Envelope getGeoReferencing(String fileName,
boolean allwaysLookForTFWExtension, Point 
imageDimensions) throws Exception {
 
@@ -610,14 +635,15 @@
}
}
return env;
-   }
+   } 
 
public static CellSizeXY getCellSize(String fileNameOrURL) throws 
Exception {
 
Point imageDims = getImageDimensions(fileNameOrURL);
 
-   Envelope envelope = getGeoReferencing(fileNameOrURL, true, new 
Point(
-   imageDims.x, imageDims.y));
+   Envelope envelope = getGeoReferencing(fileNameOrURL);
+   //  Envelope envelope = getGeoReferencing(fileNameOrURL, true, new 
Point(
+// imageDims.x, imageDims.y));
double cellSizeX = (envelope.getMaxX() - envelope.getMinX())
/ imageDims.x;
double cellSizeY = (envelope.getMaxY() - envelope.getMinY())
@@ -839,9 +865,9 @@
public static