Re: [JPP-Devel] SVN: [6517] core/trunk/src/com/vividsolutions/jump/workbench/imagery/ geotiff

2020-09-22 Thread Michaud Michael


Hi Ede,Answers inlineenvoyé : 22 septembre 2020 à 22:43de : edgar.sol...@web.deà : jump-pilot-devel@lists.sourceforge.netobjet : Re: [JPP-Devel] SVN: [6517] core/trunk/src/com/vividsolutions/jump/workbench/imagery/ geotiffhey Mike, questions inlineOn 22.09.2020 16:56, jump-pilot-svn--- via Jump-pilot-devel wrote:Revision: 6517 http://sourceforge.net/p/jump-pilot/code/6517Author: michaudmDate: 2020-09-22 14:56:54 + (Tue, 22 Sep 2020)Log Message:---Do not use RasterPainter, inherit from GeoImage and use superclass paint method instead (avoid redundant and error-prone code)Modified Paths:-- core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/RasterPainter.javaModified: core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java>SNIP@@ -217,9 +217,19 @@ void setEnvelope() {+ //Coordinate coorRaster_imageLB = new Coordinate(+ // coorRasterTiff_tiepointLT.x, src.getHeight(), 0);+ //Coordinate coorRaster_imageRT = new Coordinate(src.getWidth(), 0, 0);+ // Get the image coordinate of the bottom left corner of the bottom left pixel+ // from the image coordinate of the center of the bottom left pixel Coordinate coorRaster_imageLB = new Coordinate(- coorRasterTiff_tiepointLT.x, src.getHeight(), 0);- Coordinate coorRaster_imageRT = new Coordinate(src.getWidth(), 0, 0);+ coorRasterTiff_tiepointLT.x-0.5,+ src.getHeight()-0.5);+ // Get the image coordinate of the top right corner of the top right pixel+ // from the image coordinate of the center of the top right pixel+ Coordinate coorRaster_imageRT = new Coordinate(+ src.getWidth()-0.5,+ -0.5); Coordinate coorModel_imageLB = rasterToModelSpace(coorRaster_imageLB); Coordinate coorModel_imageRT = rasterToModelSpace(coorRaster_imageRT);what does this change do? seems you didn't mention it in the commit messageFixes the 0.5 pixel shift. I have considered that upper left and lower right tiepoints are tiedwith model coordinates representing the center of the pixel, hence the need to get imagecoordinate -0.5, -0.5 in order to compute model coordinates completely including image pixels.Modified: core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java===--- core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java 2020-09-22 12:06:16 UTC (rev 6516)+++ core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java 2020-09-22 14:56:54 UTC (rev 6517)@@ -36,16 +36,18 @@ import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.workbench.imagery.ReferencedImage; import com.vividsolutions.jump.workbench.imagery.ReferencedImageException;+import com.vividsolutions.jump.workbench.imagery.geoimg.GeoImage; import com.vividsolutions.jump.workbench.ui.Viewport; /** * legacy GeoTIFF reader */-public class GeoTIFFImage implements ReferencedImage {+public class GeoTIFFImage extends GeoImage implements ReferencedImage { private GeoTIFFRaster gtr;- private RasterPainter rasterPainter;+ //private RasterPainter rasterPainter; public GeoTIFFImage(String location) throws JUMPException {SNIPseems your doing a lot of work on the GeoTIFF Plus driver. does the XTIFF JAI reader work well for you? shouldn't we strive to move the readers strengths into the geoimg framework? actually i wrote geoimg using the geotiff driver as starting point, that's why they're so similar.I spent some time trying to fix georeferencement (0.5 pixel shift) in GeoTiff, but as the code was redundant with the one of geoimg, and you told me that geoimg was more recent, I finally used inheritance, to be able to reuse geoimg paint method in GeoTiff driver. Maybe we can go further to merge geotiff driver into geoimg, but don't get me wrong, I brought GeoTiff driver closer to geoimg.Michaël..ede___Jump-pilot-devel mailing listJump-pilot-devel@lists.sourceforge.nethttps://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] 6506 loading raster test

2020-09-22 Thread Roberto Rossi

Hello Edgard,
i repeated the test with the "-v trace" option... the log is really 
verbose now: from 50 to 15000 kb! :-)


I tried at first to load the shapefiles 
, 
the error raised at the 7th raster 
 
loaded.

You can find documentation in the /openjump1.log
/

Loading the rasters 
altogether: 
I had the error loading one of the last rasters; you can find 
documentation in the /openjump2.log/

/
/ 

Here you can find the log files 


/
/
/Thank you
/

Roberto

Il 22/09/2020 15:44, edgar.sol...@web.de ha scritto:

hey Roberto,

the verbosity setting was just added to the start scripts, so it is 
not actually documented yet. looks like your on windows.


on windows
edit 'bin/oj_windows.bat'

find

rem -- set some default OJ options here (eg. -v debug), initialize 
empty --

rem -- run OJ with '--help' argument to find out which are available --
set JUMP_OPTS=

change it to it to

rem -- set some default OJ options here (eg. -v debug), initialize 
empty --

rem -- run OJ with '--help' argument to find out which are available --
set "JUMP_OPTS=-v trace"

NOTE the double quotes around the whole assignment. this will make OJ 
somewhat slower, so you might want to leave it deactivated in production.


for linux/macos you will find the same setting in 'bin/oj_linux.sh'

## uncomment and edit if you want some default OJ parameter set
## run OJ with '--help' argument to find out which are available
#JUMP_OPTS="-v DEBUG"

where you need to uncomment it and change it to trace.

can you please redo your tests as without proper error stacks the logs 
are not helpful at all ;) .. thx! ede



On 9/21/2020 23:34, Roberto Rossi wrote:

Hello,
tank you for the big effort in developing this powerful software!

I just tested the 6506 release.
(I wasn't able to use "-v trace": where should I set this option, or 
where can I find instructions?)


I tried at first to load 2 shapefiles 
, 
and then one the raster you can find here. 

I had the yellow band error /(Array Index Out Of Bounds Exception)/: 
you can find documentation in the /openjump1.log

/

I turn off and executed again openjump. I loaded the rasters 
altogether: 
I had the error after about half rasters where loaded: you can find 
documentation in the /openjump2.log/

/
/
I don't have the same problems with the 1.15 release/
/

Roberto Rossi

Il 21/09/2020 18:31, edgar.sol...@web.de ha scritto:

On 21.09.2020 17:19, Giuseppe Aruta wrote:

Hi Ede,
it works fine. I was able to cut a selected part of the image. And 
also I tested on some simple  tools form Sextante that generate 
raster (Rasterize a vector layer, change no data value..).
Let us wait for Roberto's test. I think that it is fixed. Also it 
is nice to reduce time raster display reusing a renderedOp cache 
mapping.
yeah let's wait. anyway please advice him to use "-v trace" for 
delivering log messages. note that it is not debug but trace which 
is the most talkative setting.


The "colors" look different because a dem raster, with only one 
band, is painted using a set of grey values between black and white 
for each cell value. Those values are defined by the range of the 
cell values. The partial raster generated by the extracting tool 
has, of coarse, a different range of values compared to the 
original dem. That's why the different greys.
It is a way to graphically represent a group of datas (generally 
elevation but also slope values, quantity of rain, insolation, etc) 
distributed (or better reconstructed) as a grid on a surface.
Of course we can change the color schema (via Layer tree, Raster 
Style) and we can omologate two rasters, with different ranges of 
values to the same color schema (saving a color schema of one and 
importing it into the second, always using via Layer tree, Raster 
Style).

make total sense when explained like that :)


.
Very good job, Ede! I think, if no other problem came from Sextante 
tools (and Roberto agree), this version will be used in the course.

let's wait and see.

homework for you is porting needed functionality from TiffUtils to 
TiffUtilsV2, so that in the end TiffUtils can be removed and only 
TiffUtilsV2 remains essentially wrapping GeoReferencedraster 
functionality.


..ede



Re: [JPP-Devel] SVN: [6517] core/trunk/src/com/vividsolutions/jump/workbench/imagery/ geotiff

2020-09-22 Thread edgar . soldin
hey Mike, questions inline

On 22.09.2020 16:56, jump-pilot-svn--- via Jump-pilot-devel wrote:
> Revision: 6517
>   http://sourceforge.net/p/jump-pilot/code/6517
> Author:   michaudm
> Date: 2020-09-22 14:56:54 + (Tue, 22 Sep 2020)
> Log Message:
> ---
> Do not use RasterPainter, inherit from GeoImage and use superclass paint 
> method instead (avoid redundant and error-prone code)
>
> Modified Paths:
> --
> 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java
> 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
> 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/RasterPainter.java
>
> Modified: 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java
>SNIP
> @@ -217,9 +217,19 @@
>
>void setEnvelope()
>{
> +  //Coordinate coorRaster_imageLB = new Coordinate(
> +  //coorRasterTiff_tiepointLT.x, src.getHeight(), 0);
> +  //Coordinate coorRaster_imageRT = new Coordinate(src.getWidth(), 0, 0);
> +  // Get the image coordinate of the bottom left corner of the bottom 
> left pixel
> +  // from the image coordinate of the center of the bottom left pixel
>Coordinate coorRaster_imageLB = new Coordinate(
> -  coorRasterTiff_tiepointLT.x, src.getHeight(), 0);
> -  Coordinate coorRaster_imageRT = new Coordinate(src.getWidth(), 0, 0);
> +  coorRasterTiff_tiepointLT.x-0.5,
> +  src.getHeight()-0.5);
> +  // Get the image coordinate of the top right corner of the top right 
> pixel
> +  // from the image coordinate of the center of the top right pixel
> +  Coordinate coorRaster_imageRT = new Coordinate(
> +src.getWidth()-0.5,
> +-0.5);
>Coordinate coorModel_imageLB = rasterToModelSpace(coorRaster_imageLB);
>Coordinate coorModel_imageRT = rasterToModelSpace(coorRaster_imageRT);

what does this change do? seems you didn't mention it in the commit message

>
> Modified: 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
> ===
> --- 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
> 2020-09-22 12:06:16 UTC (rev 6516)
> +++ 
> core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
> 2020-09-22 14:56:54 UTC (rev 6517)
> @@ -36,16 +36,18 @@
>  import com.vividsolutions.jump.feature.Feature;
>  import com.vividsolutions.jump.workbench.imagery.ReferencedImage;
>  import com.vividsolutions.jump.workbench.imagery.ReferencedImageException;
> +import com.vividsolutions.jump.workbench.imagery.geoimg.GeoImage;
>  import com.vividsolutions.jump.workbench.ui.Viewport;
>
>  /**
>   * legacy GeoTIFF reader
>   */
> -public class GeoTIFFImage implements ReferencedImage {
> +public class GeoTIFFImage extends GeoImage implements ReferencedImage  {
>private GeoTIFFRaster gtr;
> -  private RasterPainter rasterPainter;
> +  //private RasterPainter rasterPainter;
>
>public GeoTIFFImage(String location) throws JUMPException {
SNIP

seems your doing a lot of work on the GeoTIFF Plus driver. does the XTIFF JAI 
reader work well for you? shouldn't we strive to move the readers strengths 
into the  geoimg framework? actually i wrote geoimg using the geotiff driver as 
starting point, that's why they're so similar.

..ede


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


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

2020-09-22 Thread edgar . soldin
On 22.09.2020 18:20, Giuseppe Aruta wrote:
> Hi Ede,
> The changes I did:
> a) remove the reading of overviews as you suggested

why didn't you disable/comment the whole method?

> b) removed the usage of commons imaging to compute some metadata
> the reason is that those metadata  are already computed by method
> GeoReferencedRaster getGeoReferencedRaster(File tiffFile), except NoData,

exactly my reasoning

> I also removed dependency to common imaging to read NoData and used
> JAI for that purpose.

if it works, it works.

> TiFFField unofficially used by GDAL to store nodata is 42113 and it is
> basically an ASCII tag.

what do you mean my "unofficially"?

> https://gdal.org/drivers/raster/gtiff.html.
> I added (lefted) also the possibility that the tag is decode as byte or
> float to  prevent errors
> With the raster files that Roberto provided, only one throws a
> NumberFormatException (depit084)

you should log an error there with the value printed to debug the value. there 
is probably an easy fix!

>so I left a standard value (-9.0D) in
> case the reading of NoData fails.
>
>

..ede


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


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

2020-09-22 Thread edgar . soldin
hey Peppe,

ajaics this still leaves

  private static ImageAndMetadata readImage(File tiffFile, int overviewIndex, 
int indexStart, Point originalSize,
  Resolution originalCellSize, Envelope wholeImageEnvelope, Envelope 
viewportEnvelope, double noDataValue,
  Stats stats) throws IOException, NoninvertibleTransformException {

ImageInputStream imageInputStream = 
ImageIO.createImageInputStream(tiffFile);
Iterator iterator = ImageIO.getImageReaders(imageInputStream);

which i'd like to see disabled/removed to prevent seeing errors from the wrong 
reader used.

..ede


On 22.09.2020 18:07, jump-pilot-svn--- via Jump-pilot-devel wrote:
> Revision: 6518
>   http://sourceforge.net/p/jump-pilot/code/6518
> Author:   ma15569
> Date: 2020-09-22 16:07:41 + (Tue, 22 Sep 2020)
> Log Message:
> ---
> Added a new method to read Image and Metadata for TIF.
> It gets rid of using Commons Imaging that sometimes throws exception
> on both reading resolution of the image. Metadata are now decoded partially 
> via loaded GeoRasterImage or by using JAI to read noData value.
> Removed code to read overviews.
>
> Modified Paths:
> --
> core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
> core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>
> Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
> ===
> --- core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java   
> 2020-09-22 14:56:54 UTC (rev 6517)
> +++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java   
> 2020-09-22 16:07:41 UTC (rev 6518)
> @@ -140,11 +140,14 @@
>  //   Overviews overviews = OverviewsUtils.getOverviews(new 
> File(
>  //   fileNameOrURL), imageEnvelope);
>
> -  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
> -  Overviews overviews = OverviewsUtils.getOverviews(new 
> File(fileNameOrURL), imageEnvelope);
> +//  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
> + // Overviews overviews = OverviewsUtils.getOverviews(new 
> File(fileNameOrURL), imageEnvelope);
>
> -  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope, requestedRes, 
> overviews, stats);
> -
> +//  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope, 
> requestedRes, overviews, stats);
> +
> +  // [Giuseppe Aruta 2020-sept-22] added new method that remove 
> overviews and gets metadata
> +  // directly from GeoRasterImage or using JAI
> +  return TiffUtilsV2.readImageAndMetadata(tiffFile, viewPortEnvelope, 
> requestedRes, stats);
>  } else if (fileNameOrURL.toLowerCase().endsWith(".flt")) {
>
>   GridFloat gf = new GridFloat(fileNameOrURL);
>
> Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
> ===
> --- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java 
> 2020-09-22 14:56:54 UTC (rev 6517)
> +++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java 
> 2020-09-22 16:07:41 UTC (rev 6518)
> @@ -29,6 +29,9 @@
>  import org.apache.commons.imaging.formats.tiff.TiffImageParser;
>  import org.xml.sax.SAXException;
>
> +import com.sun.media.jai.codec.FileSeekableStream;
> +import com.sun.media.jai.codec.TIFFDirectory;
> +import com.sun.media.jai.codec.TIFFField;
>  import com.vividsolutions.jts.geom.Coordinate;
>  import com.vividsolutions.jts.geom.Envelope;
>  import com.vividsolutions.jump.workbench.Logger;
> @@ -90,6 +93,7 @@
>  return JAI.create("scale", parameterBlock);
>}
>
> +
>/**
> * Method to build an ImageAndMetadata file
> * An ImageAndMetadata groups the Envelope, the Image, the Statistics and
> @@ -201,7 +205,134 @@
>   }
>
> }
> +
> +
> +
> +
> +
> +  /**
> +   * New method to build an ImageAndMetadata file
> +   * An ImageAndMetadata groups the Envelope, the Image, the Statistics and
> +   * NoData value of a TIF file
> +   * Removed reading overviews and dependency to commons imaging library
> +   * @param tiffFile
> +   * @param viewportEnvelope
> +   * @param requestedRes
> +   * @param stats
> +   * @return ImageAndMetadata
> +   * @throws NoninvertibleTransformException
> +   * @throws IOException
> +   * @throws FileNotFoundException
> +   * @throws TiffTags.TiffReadingException
> +   * @throws Exception
> +   */
> +  public static ImageAndMetadata readImageAndMetadata(File tiffFile, 
> Envelope viewportEnvelope, Resolution requestedRes,
> +  Stats stats) throws NoninvertibleTransformException, IOException, 
> FileNotFoundException,
> +   TiffTags.TiffReadingException, Exception {
> +   RenderedOp renderedOp1 = getRenderedOp(tiffFile);
> +   Envelope wholeImageEnvelope = getEnvelope(tiffFile);
> +
> +   //[Giuseppe Aruta 2020-sept-22] Deactivated Commons Imaging  class>
> + 

Re: [JPP-Devel] Fwd: [jira] [Commented] (IMAGING-267) Colorful rendering of b/w Monoband TIF

2020-09-22 Thread edgar . soldin
Peppe,

would you mind posting your answer in the jira ticket [1] or do you want me to 
post it in your stead?

..ede

[1] 
https://issues.apache.org/jira/browse/IMAGING-267?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel=17200118#comment-17200118

On 22.09.2020 18:37, Giuseppe Aruta wrote:
> /First off, this TIFF appears to be geophysical data.  But there are no 
> GeoTIFF tags bundled with the image. Judging from the ModelTiepointTag, it 
> appears that the original image was configured using a projected coordinate 
> system, maybe a UTM zone.  It might help me understand this better if there 
> were more location information attached to the image. Do you have that 
> information?/
>
> No. This image comes from image samples used by Victor Oyala to test Sextante 
> and had no attached crs . I think this image is related to an UTM zone in 
> Spain.
>
> /Secondly, I note that this TIFF file is not strictly-speaking an image , but 
> is actually numerical data stored using the TIFF standard floating-point 
> raster format.  My guess is that it's probably elevations. The ability to 
> process TIFF files containing floating point data was introduced in the most 
> recent release of Commons Imaging./
>
> Yes, Those are elevation data
>
> /I've attached the image I produced (ISSUE_267.JPG).  However, to create it, 
> I had to know before hand what the range of values was.  So my application 
> does a few extra steps that I did not show in the example above.  I was 
> wondering how the software you used handles this issue.  Is it all automatic?/
>
> Yes. In OpenJUMP reads the range either in a aux.xml sidecar file or it 
> computes using JAI.create("extrema") method
>
> /Also, a second question I had is that the PhotometricInterpretation tag 
> given with your image is 1, which means "0 is black".   In other words, the 
> palette should range from the darkest shading for the lowest numerical values 
> to the lightest shading for the highest values. However, in looking at your 
> image I notice that the lowest value pixels are drawn in the lightest colors, 
> which seems to contradict the setting in the source TIFF file.  In the image 
> I've attached, the lowest value pixels are draw in the darkest colors, which 
> is consistent with the specification in the TIFF image.  Is there some 
> setting in the application you used that overwrites the settings from the 
> TIFF file?/
>
> The  buffered Image to display into the view of the monoband is overwritten  
> in order to define a range of colours used to display it (I think it is the 
> method stretchImageValuesForDisplay() in RasterImage class). This method 
> defines the range of colour (Bloack to white) and saves as 
> RasterImageSymbology map (sorry for bad explanation). Thus we can change the 
> range of colours, creating a discrete range instead of continuous one, set a 
> subrange/value of the pixel to a specific colour
>
> Il giorno mar 22 set 2020 alle ore 15:33  > ha scritto:
>
> hey Gang,
>
> Gary at Apache-Commons-Imaging has some questions regarding a monoband 
> TIF i provided. would one of you with a deeper knowledge of rasters (Peppe, 
> Jukka, both?) answer him please in the ticket linked below (you need an 
> account, so may have to register, but it's painless and fast).
>
> thanks.. ede
>
>
>  Forwarded Message 
> Subject: [jira] [Commented] (IMAGING-267) Colorful rendering of b/w 
> Monoband TIF
> Date: Tue, 22 Sep 2020 00:06:00 + (UTC)
> From: Gary Lucas (Jira) mailto:j...@apache.org>>
> To: edgar.sol...@web.de 
>
>
>      [ 
> https://issues.apache.org/jira/browse/IMAGING-267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17199709#comment-17199709
>  
> 
>  ]
>
> Gary Lucas commented on IMAGING-267:
> 
>
> Thank you for posting the images. They may help to answer some issues 
> I've wondered about for awhile.  I've inspected their content and I have a 
> few questions for you.
>
> First off, this TIFF appears to be geophysical data.  But there are no 
> GeoTIFF tags bundled with the image. Judging from the ModelTiepointTag, it 
> appears that the original image was configured using a projected coordinate 
> system, maybe a UTM zone.  It might help me understand this better if there 
> were more location information attached to the image. Do you have that 
> information?
>
> Secondly, I note that this TIFF file is not strictly-speaking an image , 
> but is actually numerical data stored using the TIFF standard floating-point 
> raster format.  My guess is that it's probably elevations. The ability to 
> process TIFF files containing floating point data was introduced in the most 
> 

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

2020-09-22 Thread Rahkonen Jukka (MML)
Hi,

What is the question? TIFF files can have either internal or external overviews 
and if client supports them it is much faster to render the image at small 
scales. I have no idea about what readers can handle internal/external 
overviews but I can arrange test images easily.
External overviews are not very common but because they are external they are 
handy for testing what resampling method feels best. Also it is easier to 
delete the .ovr file than the internal overviews if user wants to archive the 
image and save the 30% of disk space that overviews take.

-Jukka Rahkonen-

Lähettäjä: Giuseppe Aruta 
Lähetetty: tiistai 22. syyskuuta 2020 17.19
Vastaanottaja: OpenJump develop and use 
Aihe: Re: [JPP-Devel] SVN: [6507] core/trunk/src/org/openjump/core/rasterimage

Let us wait  for Michael and Jukka's opinion about it.
I am not sure but possibly it was request by one of the member of the list 
years ago to Alberto De Luca who implemented this part of the code.
I prefer to  comment out and build a new clean method

Il giorno mar 22 set 2020 alle ore 15:29 
mailto:edgar.sol...@web.de>> ha scritto:


On 9/22/2020 13:49, Giuseppe Aruta wrote:
>> +   private static ImageAndMetadata readImage(File tiffFile, int 
>> overviewIndex, int indexStart, Point originalSize,
>> +   Resolution originalCellSize, Envelope wholeImageEnvelope, 
>> Envelope viewportEnvelope, double noDataValue,
>> +   Stats stats) throws IOException, NoninvertibleTransformException 
>> {
>> +
>> + ImageInputStream imageInputStream = 
>> ImageIO.createImageInputStream(tiffFile);
>> + Iterator iterator = 
>> ImageIO.getImageReaders(imageInputStream);
>
> this seems to be a leftover. we want to enforce a specific TIFF reader, which 
> seems not to be done here.
>
> why exactly are there two readImage() methods needed anyway? one should 
> suffice. can you remove it?
>
> Not sure. As it tries to read overviews of a file from an external .ovr file. 
> I have never used or found it in projects. Once I tried to save a tiff with 
> overviews using QGIS: I had back two files, a TIF and a OVR one. But when I 
> tried to load this  couple into OpenJUMP, it took so long that I gave up. 
> AFAIR this was a request of many years ago from someone of the list

why not remove it then, if it's not used or working anyway? if you want to keep 
it, to have a go at it in the future, i'd suggest to at least to deactivate it, 
just to make sure it is no code path used accidentially.

a hack i use sometimes is to add

// explain why!
if (true) throw new java.lang.UnsupportedOperationException();

before some code i want to deactivate. this way the code does not have to be 
commented out and stays readable but will not be used anyway.

..ede


___
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


[JPP-Devel] RasterizePlugIn

2020-09-22 Thread Michaud Michael


Peppe,RasterizePlugIn is an interesting addition. Maybe you have not completely finished, sorry, I saw this today and had some time in the train to make a quick review :- plugin is not activated yet (not in default-plugin.xml)- not fully internationalized (method getName)- would be nice to have more comments/javadoc- plugin throws a NPE if selected attribute contains nulls- RasterizeAlgorithm class : why don't you stick to CamelCase conventions for method names ?About the UI :The layer combobox is added 2 times, one with the MultiInputDialogframework and one is created manually and added with MultiFormUtils.Why did you try to manage the LayerComboBox manually ?Try to stick to MultiInputDialog as much as possible. Missing capabilitiesmay be discussed on the listAbout design or code detailsYou added new methods in FeatureCollectionUtil to validate and unionfeatures, but methods are 80% redundant with existing plugins. - Making a geometry valid is a single method call : maybe it is notuseful to iterate several times through the collection to make geometriesvalid, then to union them- Union is a costly operation : would be interesting to check thatunioning before rasterizing is worthwhile (I suppose rasterizingeach single feature would produce the same result, even in case or overlaps). Is it faster to union before or do you get a different result ?- You make features valid without cloning them : it means you change actual geometries. Are you sure the user want to change its geometries ? Cannot be reverted.- UnionByAttributeValue : you only need geometry and an attribute for the result schema. Other attributes are undefined (null in your case). Not a big problem though.- UnionByAttributeValue : line 141 do nothing featureCollection.getFeatures().get(0).getGeometry().getFactory();- UnionByAttributeValue : lines 146, 147 do nothing useful(using newSchema after that is just like using schema) FeatureSchema newSchema;newSchema = schema;Michaël

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


Re: [JPP-Devel] Fwd: [jira] [Commented] (IMAGING-267) Colorful rendering of b/w Monoband TIF

2020-09-22 Thread Giuseppe Aruta
*First off, this TIFF appears to be geophysical data.  But there are no
GeoTIFF tags bundled with the image. Judging from the ModelTiepointTag, it
appears that the original image was configured using a projected coordinate
system, maybe a UTM zone.  It might help me understand this better if there
were more location information attached to the image. Do you have that
information?*

No. This image comes from image samples used by Victor Oyala to test
Sextante and had no attached crs . I think this image is related to an UTM
zone in Spain.

*Secondly, I note that this TIFF file is not strictly-speaking an image ,
but is actually numerical data stored using the TIFF standard
floating-point raster format.  My guess is that it's probably elevations.
The ability to process TIFF files containing floating point data was
introduced in the most recent release of Commons Imaging.*

Yes, Those are elevation data

*I've attached the image I produced (ISSUE_267.JPG).  However, to create
it, I had to know before hand what the range of values was.  So my
application does a few extra steps that I did not show in the example
above.  I was wondering how the software you used handles this issue.  Is
it all automatic?*

Yes. In OpenJUMP reads the range either in a aux.xml sidecar file or it
computes using JAI.create("extrema") method

*Also, a second question I had is that the PhotometricInterpretation tag
given with your image is 1, which means "0 is black".   In other words, the
palette should range from the darkest shading for the lowest numerical
values to the lightest shading for the highest values. However, in looking
at your image I notice that the lowest value pixels are drawn in the
lightest colors, which seems to contradict the setting in the source TIFF
file.  In the image I've attached, the lowest value pixels are draw in the
darkest colors, which is consistent with the specification in the TIFF
image.  Is there some setting in the application you used that overwrites
the settings from the TIFF file?*

The  buffered Image to display into the view of the monoband is
overwritten  in order to define a range of colours used to display it (I
think it is the method stretchImageValuesForDisplay() in RasterImage
class). This method defines the range of colour (Bloack to white) and saves
as RasterImageSymbology map (sorry for bad explanation). Thus we can change
the range of colours, creating a discrete range instead of continuous one,
set a subrange/value of the pixel to a specific colour

Il giorno mar 22 set 2020 alle ore 15:33  ha scritto:

> hey Gang,
>
> Gary at Apache-Commons-Imaging has some questions regarding a monoband TIF
> i provided. would one of you with a deeper knowledge of rasters (Peppe,
> Jukka, both?) answer him please in the ticket linked below (you need an
> account, so may have to register, but it's painless and fast).
>
> thanks.. ede
>
>
>  Forwarded Message 
> Subject: [jira] [Commented] (IMAGING-267) Colorful rendering of b/w
> Monoband TIF
> Date: Tue, 22 Sep 2020 00:06:00 + (UTC)
> From: Gary Lucas (Jira) 
> To: edgar.sol...@web.de
>
>
>  [
> https://issues.apache.org/jira/browse/IMAGING-267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17199709#comment-17199709
> ]
>
> Gary Lucas commented on IMAGING-267:
> 
>
> Thank you for posting the images. They may help to answer some issues I've
> wondered about for awhile.  I've inspected their content and I have a few
> questions for you.
>
> First off, this TIFF appears to be geophysical data.  But there are no
> GeoTIFF tags bundled with the image. Judging from the ModelTiepointTag, it
> appears that the original image was configured using a projected coordinate
> system, maybe a UTM zone.  It might help me understand this better if there
> were more location information attached to the image. Do you have that
> information?
>
> Secondly, I note that this TIFF file is not strictly-speaking an image ,
> but is actually numerical data stored using the TIFF standard
> floating-point raster format.  My guess is that it's probably elevations.
> The ability to process TIFF files containing floating point data was
> introduced in the most recent release of Commons Imaging.
>
> One challenge of floating point images is how to map the range of values
> to gray scale. In this case, the following text gives the TIFF Tags
> attached to the image:
>
> Directory 0 Has TIFF Image Data, description: Root
>   256 (0x100: ImageWidth): 601 (1 Long)
>   257 (0x101: ImageLength): 410 (1 Long)
>   258 (0x102: BitsPerSample): 32 (1 Short)
>   259 (0x103: Compression): 1 (1 Short)
>   262 (0x106: PhotometricInterpretation): 1 (Indicates "zero is black")
>   277 (0x115: SamplesPerPixel): 1 (1 Short)
>   278 (0x116: RowsPerStrip): 8 (1 Long)
>   339 (0x153: SampleFormat): 3 (Indicates float-point format)
>   33550 (0x830e: ModelPixelScaleTag): 25.0, 25.0 (2 Double)
>   33922 (0x8482: 

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

2020-09-22 Thread Giuseppe Aruta
Removing common imaging also "prodigiously" solved the problem on AsterDem
dimension that Michael described in a previous post

Il giorno mar 22 set 2020 alle ore 18:20 Giuseppe Aruta <
giuseppe.ar...@gmail.com> ha scritto:

> Hi Ede,
> The changes I did:
> a) remove the reading of overviews as you suggested
> b) removed the usage of commons imaging to compute some metadata
> the reason is that those metadata  are already computed by method
> GeoReferencedRaster getGeoReferencedRaster(File tiffFile), except NoData,
> I also removed dependency to common imaging to read NoData and used
> JAI for that purpose.
> TiFFField unofficially used by GDAL to store nodata is 42113 and it is
> basically an ASCII tag.
> https://gdal.org/drivers/raster/gtiff.html.
> I added (lefted) also the possibility that the tag is decode as byte or
> float to  prevent errors
> With the raster files that Roberto provided, only one throws a
> NumberFormatException (depit084) so I left a standard value (-9.0D) in
> case the reading of NoData fails.
>
>
> Il giorno mar 22 set 2020 alle ore 18:07 jump-pilot-svn--- via
> Jump-pilot-devel  ha scritto:
>
>> Revision: 6518
>>   http://sourceforge.net/p/jump-pilot/code/6518
>> Author:   ma15569
>> Date: 2020-09-22 16:07:41 + (Tue, 22 Sep 2020)
>> Log Message:
>> ---
>> Added a new method to read Image and Metadata for TIF.
>> It gets rid of using Commons Imaging that sometimes throws exception
>> on both reading resolution of the image. Metadata are now decoded
>> partially via loaded GeoRasterImage or by using JAI to read noData value.
>> Removed code to read overviews.
>>
>> Modified Paths:
>> --
>> core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
>> core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>>
>> Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
>> ===
>> --- core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
>>  2020-09-22 14:56:54 UTC (rev 6517)
>> +++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
>>  2020-09-22 16:07:41 UTC (rev 6518)
>> @@ -140,11 +140,14 @@
>>  // Overviews overviews =
>> OverviewsUtils.getOverviews(new File(
>>  // fileNameOrURL), imageEnvelope);
>>
>> -  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
>> -  Overviews overviews = OverviewsUtils.getOverviews(new
>> File(fileNameOrURL), imageEnvelope);
>> +//  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
>> + // Overviews overviews = OverviewsUtils.getOverviews(new
>> File(fileNameOrURL), imageEnvelope);
>>
>> -  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope,
>> requestedRes, overviews, stats);
>> -
>> +//  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope,
>> requestedRes, overviews, stats);
>> +
>> +  // [Giuseppe Aruta 2020-sept-22] added new method that remove
>> overviews and gets metadata
>> +  // directly from GeoRasterImage or using JAI
>> +  return TiffUtilsV2.readImageAndMetadata(tiffFile,
>> viewPortEnvelope, requestedRes, stats);
>>  } else if (fileNameOrURL.toLowerCase().endsWith(".flt")) {
>>
>> GridFloat gf = new GridFloat(fileNameOrURL);
>>
>> Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>> ===
>> --- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>>  2020-09-22 14:56:54 UTC (rev 6517)
>> +++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>>  2020-09-22 16:07:41 UTC (rev 6518)
>> @@ -29,6 +29,9 @@
>>  import org.apache.commons.imaging.formats.tiff.TiffImageParser;
>>  import org.xml.sax.SAXException;
>>
>> +import com.sun.media.jai.codec.FileSeekableStream;
>> +import com.sun.media.jai.codec.TIFFDirectory;
>> +import com.sun.media.jai.codec.TIFFField;
>>  import com.vividsolutions.jts.geom.Coordinate;
>>  import com.vividsolutions.jts.geom.Envelope;
>>  import com.vividsolutions.jump.workbench.Logger;
>> @@ -90,6 +93,7 @@
>>  return JAI.create("scale", parameterBlock);
>>}
>>
>> +
>>/**
>> * Method to build an ImageAndMetadata file
>> * An ImageAndMetadata groups the Envelope, the Image, the Statistics
>> and
>> @@ -201,7 +205,134 @@
>> }
>>
>>   }
>> +
>> +
>> +
>> +
>> +
>> +  /**
>> +   * New method to build an ImageAndMetadata file
>> +   * An ImageAndMetadata groups the Envelope, the Image, the Statistics
>> and
>> +   * NoData value of a TIF file
>> +   * Removed reading overviews and dependency to commons imaging library
>> +   * @param tiffFile
>> +   * @param viewportEnvelope
>> +   * @param requestedRes
>> +   * @param stats
>> +   * @return ImageAndMetadata
>> +   * @throws NoninvertibleTransformException
>> +   * @throws IOException
>> +   * @throws FileNotFoundException
>> 

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

2020-09-22 Thread Giuseppe Aruta
Hi Ede,
The changes I did:
a) remove the reading of overviews as you suggested
b) removed the usage of commons imaging to compute some metadata
the reason is that those metadata  are already computed by method
GeoReferencedRaster getGeoReferencedRaster(File tiffFile), except NoData,
I also removed dependency to common imaging to read NoData and used
JAI for that purpose.
TiFFField unofficially used by GDAL to store nodata is 42113 and it is
basically an ASCII tag.
https://gdal.org/drivers/raster/gtiff.html.
I added (lefted) also the possibility that the tag is decode as byte or
float to  prevent errors
With the raster files that Roberto provided, only one throws a
NumberFormatException (depit084) so I left a standard value (-9.0D) in
case the reading of NoData fails.


Il giorno mar 22 set 2020 alle ore 18:07 jump-pilot-svn--- via
Jump-pilot-devel  ha scritto:

> Revision: 6518
>   http://sourceforge.net/p/jump-pilot/code/6518
> Author:   ma15569
> Date: 2020-09-22 16:07:41 + (Tue, 22 Sep 2020)
> Log Message:
> ---
> Added a new method to read Image and Metadata for TIF.
> It gets rid of using Commons Imaging that sometimes throws exception
> on both reading resolution of the image. Metadata are now decoded
> partially via loaded GeoRasterImage or by using JAI to read noData value.
> Removed code to read overviews.
>
> Modified Paths:
> --
> core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
> core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>
> Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
> ===
> --- core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
>  2020-09-22 14:56:54 UTC (rev 6517)
> +++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
>  2020-09-22 16:07:41 UTC (rev 6518)
> @@ -140,11 +140,14 @@
>  // Overviews overviews =
> OverviewsUtils.getOverviews(new File(
>  // fileNameOrURL), imageEnvelope);
>
> -  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
> -  Overviews overviews = OverviewsUtils.getOverviews(new
> File(fileNameOrURL), imageEnvelope);
> +//  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
> + // Overviews overviews = OverviewsUtils.getOverviews(new
> File(fileNameOrURL), imageEnvelope);
>
> -  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope,
> requestedRes, overviews, stats);
> -
> +//  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope,
> requestedRes, overviews, stats);
> +
> +  // [Giuseppe Aruta 2020-sept-22] added new method that remove
> overviews and gets metadata
> +  // directly from GeoRasterImage or using JAI
> +  return TiffUtilsV2.readImageAndMetadata(tiffFile, viewPortEnvelope,
> requestedRes, stats);
>  } else if (fileNameOrURL.toLowerCase().endsWith(".flt")) {
>
> GridFloat gf = new GridFloat(fileNameOrURL);
>
> Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
> ===
> --- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>  2020-09-22 14:56:54 UTC (rev 6517)
> +++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>  2020-09-22 16:07:41 UTC (rev 6518)
> @@ -29,6 +29,9 @@
>  import org.apache.commons.imaging.formats.tiff.TiffImageParser;
>  import org.xml.sax.SAXException;
>
> +import com.sun.media.jai.codec.FileSeekableStream;
> +import com.sun.media.jai.codec.TIFFDirectory;
> +import com.sun.media.jai.codec.TIFFField;
>  import com.vividsolutions.jts.geom.Coordinate;
>  import com.vividsolutions.jts.geom.Envelope;
>  import com.vividsolutions.jump.workbench.Logger;
> @@ -90,6 +93,7 @@
>  return JAI.create("scale", parameterBlock);
>}
>
> +
>/**
> * Method to build an ImageAndMetadata file
> * An ImageAndMetadata groups the Envelope, the Image, the Statistics
> and
> @@ -201,7 +205,134 @@
> }
>
>   }
> +
> +
> +
> +
> +
> +  /**
> +   * New method to build an ImageAndMetadata file
> +   * An ImageAndMetadata groups the Envelope, the Image, the Statistics
> and
> +   * NoData value of a TIF file
> +   * Removed reading overviews and dependency to commons imaging library
> +   * @param tiffFile
> +   * @param viewportEnvelope
> +   * @param requestedRes
> +   * @param stats
> +   * @return ImageAndMetadata
> +   * @throws NoninvertibleTransformException
> +   * @throws IOException
> +   * @throws FileNotFoundException
> +   * @throws TiffTags.TiffReadingException
> +   * @throws Exception
> +   */
> +  public static ImageAndMetadata readImageAndMetadata(File tiffFile,
> Envelope viewportEnvelope, Resolution requestedRes,
> +Stats stats) throws NoninvertibleTransformException,
> IOException, FileNotFoundException,
> + TiffTags.TiffReadingException, 

[JPP-Devel] SVN: [6519] core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6519
  http://sourceforge.net/p/jump-pilot/code/6519
Author:   ma15569
Date: 2020-09-22 16:08:22 + (Tue, 22 Sep 2020)
Log Message:
---
correct typo

Modified Paths:
--
core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java

Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 16:07:41 UTC (rev 6518)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 16:08:22 UTC (rev 6519)
@@ -274,7 +274,7 @@
 } catch (NumberFormatException e){
   //[Giuseppe Aruta 2020-sept-22]
//Sometimes reading NoData fails with NumberFormatException
-   //Thus the rastee is not well displayed in the view
+   //Thus the raster is not well displayed in the view
//This code sets a standard (Saga gis) noData value readable for 
OpenJUMP
noData=-9.0D;
 }



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


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

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6518
  http://sourceforge.net/p/jump-pilot/code/6518
Author:   ma15569
Date: 2020-09-22 16:07:41 + (Tue, 22 Sep 2020)
Log Message:
---
Added a new method to read Image and Metadata for TIF.
It gets rid of using Commons Imaging that sometimes throws exception 
on both reading resolution of the image. Metadata are now decoded partially via 
loaded GeoRasterImage or by using JAI to read noData value.
Removed code to read overviews.

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

Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
===
--- core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java 
2020-09-22 14:56:54 UTC (rev 6517)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java 
2020-09-22 16:07:41 UTC (rev 6518)
@@ -140,11 +140,14 @@
 // Overviews overviews = OverviewsUtils.getOverviews(new 
File(
 // fileNameOrURL), imageEnvelope);
 
-  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
-  Overviews overviews = OverviewsUtils.getOverviews(new 
File(fileNameOrURL), imageEnvelope);
+//  Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
+ // Overviews overviews = OverviewsUtils.getOverviews(new 
File(fileNameOrURL), imageEnvelope);
 
-  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope, requestedRes, 
overviews, stats);
-
+//  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope, requestedRes, 
overviews, stats);
+  
+  // [Giuseppe Aruta 2020-sept-22] added new method that remove overviews 
and gets metadata
+  // directly from GeoRasterImage or using JAI
+  return TiffUtilsV2.readImageAndMetadata(tiffFile, viewPortEnvelope, 
requestedRes, stats);
 } else if (fileNameOrURL.toLowerCase().endsWith(".flt")) {
 
GridFloat gf = new GridFloat(fileNameOrURL);

Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 14:56:54 UTC (rev 6517)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 16:07:41 UTC (rev 6518)
@@ -29,6 +29,9 @@
 import org.apache.commons.imaging.formats.tiff.TiffImageParser;
 import org.xml.sax.SAXException;
 
+import com.sun.media.jai.codec.FileSeekableStream;
+import com.sun.media.jai.codec.TIFFDirectory;
+import com.sun.media.jai.codec.TIFFField;
 import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.Envelope;
 import com.vividsolutions.jump.workbench.Logger;
@@ -90,6 +93,7 @@
 return JAI.create("scale", parameterBlock);
   }
   
+  
   /**
* Method to build an ImageAndMetadata file
* An ImageAndMetadata groups the Envelope, the Image, the Statistics and 
@@ -201,7 +205,134 @@
}
 
  }
+  
+  
+  
+  
+  
+  /**
+   * New method to build an ImageAndMetadata file
+   * An ImageAndMetadata groups the Envelope, the Image, the Statistics and 
+   * NoData value of a TIF file
+   * Removed reading overviews and dependency to commons imaging library
+   * @param tiffFile
+   * @param viewportEnvelope
+   * @param requestedRes
+   * @param stats
+   * @return ImageAndMetadata
+   * @throws NoninvertibleTransformException
+   * @throws IOException
+   * @throws FileNotFoundException
+   * @throws TiffTags.TiffReadingException
+   * @throws Exception
+   */
+  public static ImageAndMetadata readImageAndMetadata(File tiffFile, Envelope 
viewportEnvelope, Resolution requestedRes,
+Stats stats) throws NoninvertibleTransformException, IOException, 
FileNotFoundException,
+ TiffTags.TiffReadingException, Exception {
+ RenderedOp renderedOp1 = getRenderedOp(tiffFile);
+ Envelope wholeImageEnvelope = getEnvelope(tiffFile);
+ 
+ //[Giuseppe Aruta 2020-sept-22] Deactivated Commons Imaging 
+ // as it throws an error on computing Resolution. 
+ // This value can be calculated from envelope and image.
+ //Deactivated code
+ // TiffTags.TiffMetadata tiffMetadata = 
TiffTags.readMetadata(tiffFile);
+ //int originalImageWidth = tiffMetadata.getColsCount();
+ //int originalImageHeight = tiffMetadata.getRowsCount();
+ // Resolution cellSize = tiffMetadata.getResolution();
+ // Double noData = tiffMetadata.getNoData();
+ 
+  //[Giuseppe Aruta 2020-sept-22]
+  // Try to read geotiff noData tag using JAI. 
+  // It also solves the  problem of the size of AsterDEM files
+  // @ TODO This part should be ported to 
+  // 

[JPP-Devel] SVN: [6517] core/trunk/src/com/vividsolutions/jump/workbench/imagery/ geotiff

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6517
  http://sourceforge.net/p/jump-pilot/code/6517
Author:   michaudm
Date: 2020-09-22 14:56:54 + (Tue, 22 Sep 2020)
Log Message:
---
Do not use RasterPainter, inherit from GeoImage and use superclass paint method 
instead (avoid redundant and error-prone code)

Modified Paths:
--

core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java

core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java

core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/RasterPainter.java

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java
===
--- 
core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java
   2020-09-22 12:06:16 UTC (rev 6516)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoReferencedRaster.java
   2020-09-22 14:56:54 UTC (rev 6517)
@@ -88,10 +88,10 @@
   // create a temp stream to find all candidate codecs
   SeekableStream is = 
SeekableStream.wrapInputStream(CompressedFile.openFile(uri),
   true);
-  String[] decs = ImageCodec.getDecoderNames((SeekableStream) is);
+  String[] decs = ImageCodec.getDecoderNames(is);
   FileUtil.close(is);
 
-  List removed_codecs = new ArrayList();
+  List removed_codecs = new ArrayList<>();
   try {
 // remove all codecs except xtiff
 if (Arrays.asList(decs).contains("xtiff")) {
@@ -100,7 +100,7 @@
 if (name!="xtiff") {
   ImageCodec.unregisterCodec(name);
   removed_codecs.add(candidate_codec);
-//  System.out.println("removed " + name);
+  //System.out.println("removed " + name);
 }
   }
 }
@@ -217,9 +217,19 @@
 
   void setEnvelope()
   {
+  //Coordinate coorRaster_imageLB = new Coordinate(
+  //coorRasterTiff_tiepointLT.x, src.getHeight(), 0);
+  //Coordinate coorRaster_imageRT = new Coordinate(src.getWidth(), 0, 0);
+  // Get the image coordinate of the bottom left corner of the bottom left 
pixel
+  // from the image coordinate of the center of the bottom left pixel
   Coordinate coorRaster_imageLB = new Coordinate(
-  coorRasterTiff_tiepointLT.x, src.getHeight(), 0);
-  Coordinate coorRaster_imageRT = new Coordinate(src.getWidth(), 0, 0);
+  coorRasterTiff_tiepointLT.x-0.5,
+  src.getHeight()-0.5);
+  // Get the image coordinate of the top right corner of the top right 
pixel
+  // from the image coordinate of the center of the top right pixel
+  Coordinate coorRaster_imageRT = new Coordinate(
+src.getWidth()-0.5,
+-0.5);
   Coordinate coorModel_imageLB = rasterToModelSpace(coorRaster_imageLB);
   Coordinate coorModel_imageRT = rasterToModelSpace(coorRaster_imageRT);
 

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
===
--- 
core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
  2020-09-22 12:06:16 UTC (rev 6516)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/imagery/geotiff/GeoTIFFImage.java
  2020-09-22 14:56:54 UTC (rev 6517)
@@ -36,16 +36,18 @@
 import com.vividsolutions.jump.feature.Feature;
 import com.vividsolutions.jump.workbench.imagery.ReferencedImage;
 import com.vividsolutions.jump.workbench.imagery.ReferencedImageException;
+import com.vividsolutions.jump.workbench.imagery.geoimg.GeoImage;
 import com.vividsolutions.jump.workbench.ui.Viewport;
 
 /**
  * legacy GeoTIFF reader
  */
-public class GeoTIFFImage implements ReferencedImage {
+public class GeoTIFFImage extends GeoImage implements ReferencedImage  {
   private GeoTIFFRaster gtr;
-  private RasterPainter rasterPainter;
+  //private RasterPainter rasterPainter;
 
   public GeoTIFFImage(String location) throws JUMPException {
+super(location, null);
 init(location);
   }
 
@@ -56,9 +58,10 @@
   private void init(String location) throws JUMPException {
 try {
   gtr = new GeoTIFFRaster(location);
-  rasterPainter = new RasterPainter(gtr);
+  //rasterPainter = new RasterPainter(gtr);
   // Try to access data and fail fast if not possible
-  rasterPainter.geoRaster.src.getData();
+  gtr.src.getData();
+  //rasterPainter.geoRaster.src.getData();
 } catch (Exception e) {
   gtr = null;
   throw new ReferencedImageException(e);
@@ -65,6 +68,7 @@
 }
   }
 
+  /*
   public void paint(Feature f, java.awt.Graphics2D g, Viewport viewport)
   throws ReferencedImageException {
 try {
@@ -73,7 +77,9 @@
   throw new ReferencedImageException(ex);
 }
   }
+  */
 
+
   public String getType() {
 return "GeoTiff";
   }

Modified: 

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

2020-09-22 Thread edgar . soldin
On 22.09.2020 16:18, Giuseppe Aruta wrote:
> I prefer to  comment out and build a new clean method

up to you. as long as it is not active while we are trying to beat it into 
shape ;).. ede


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


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

2020-09-22 Thread Giuseppe Aruta
Let us wait  for Michael and Jukka's opinion about it.
I am not sure but possibly it was request by one of the member of the list
years ago to Alberto De Luca who implemented this part of the code.
I prefer to  comment out and build a new clean method

Il giorno mar 22 set 2020 alle ore 15:29  ha scritto:

>
>
> On 9/22/2020 13:49, Giuseppe Aruta wrote:
> >> +   private static ImageAndMetadata readImage(File tiffFile, int
> overviewIndex, int indexStart, Point originalSize,
> >> +   Resolution originalCellSize, Envelope wholeImageEnvelope,
> Envelope viewportEnvelope, double noDataValue,
> >> +   Stats stats) throws IOException,
> NoninvertibleTransformException {
> >> +
> >> + ImageInputStream imageInputStream =
> ImageIO.createImageInputStream(tiffFile);
> >> + Iterator iterator =
> ImageIO.getImageReaders(imageInputStream);
> >
> > this seems to be a leftover. we want to enforce a specific TIFF reader,
> which seems not to be done here.
> >
> > why exactly are there two readImage() methods needed anyway? one should
> suffice. can you remove it?
> >
> > Not sure. As it tries to read overviews of a file from an external .ovr
> file. I have never used or found it in projects. Once I tried to save a
> tiff with overviews using QGIS: I had back two files, a TIF and a OVR one.
> But when I tried to load this  couple into OpenJUMP, it took so long that I
> gave up. AFAIR this was a request of many years ago from someone of the list
>
> why not remove it then, if it's not used or working anyway? if you want to
> keep it, to have a go at it in the future, i'd suggest to at least to
> deactivate it, just to make sure it is no code path used accidentially.
>
> a hack i use sometimes is to add
>
> // explain why!
> if (true) throw new java.lang.UnsupportedOperationException();
>
> before some code i want to deactivate. this way the code does not have to
> be commented out and stays readable but will not be used anyway.
>
> ..ede
>
>
> ___
> 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] 6506 loading raster test

2020-09-22 Thread edgar . soldin

hey Roberto,

the verbosity setting was just added to the start scripts, so it is not 
actually documented yet. looks like your on windows.

on windows
edit 'bin/oj_windows.bat'

find

rem -- set some default OJ options here (eg. -v debug), initialize empty --
rem -- run OJ with '--help' argument to find out which are available --
set JUMP_OPTS=

change it to it to

rem -- set some default OJ options here (eg. -v debug), initialize empty --
rem -- run OJ with '--help' argument to find out which are available --
set "JUMP_OPTS=-v trace"

NOTE the double quotes around the whole assignment. this will make OJ somewhat 
slower, so you might want to leave it deactivated in production.

for linux/macos you will find the same setting in 'bin/oj_linux.sh'

## uncomment and edit if you want some default OJ parameter set
## run OJ with '--help' argument to find out which are available
#JUMP_OPTS="-v DEBUG"

where you need to uncomment it and change it to trace.

can you please redo your tests as without proper error stacks the logs are not 
helpful at all ;) .. thx! ede


On 9/21/2020 23:34, Roberto Rossi wrote:

Hello,
tank you for the big effort in developing this powerful software!

I just tested the 6506 release.
(I wasn't able to use "-v trace": where should I set this option, or where can 
I find instructions?)

I tried at first to load 2 shapefiles 
, and 
then one the raster you can find here. 

I had the yellow band error /(Array Index Out Of Bounds Exception)/: you can 
find documentation in the /openjump1.log
/

I turn off and executed again openjump. I loaded the rasters 
altogether:
 I had the error after about half rasters where loaded: you can find documentation in the 
/openjump2.log/
/
/
I don't have the same problems with the 1.15 release/
/

Roberto Rossi

Il 21/09/2020 18:31, edgar.sol...@web.de ha scritto:

On 21.09.2020 17:19, Giuseppe Aruta wrote:

Hi Ede,
it works fine. I was able to cut a selected part of the image. And also I 
tested on some simple  tools form Sextante that generate raster (Rasterize a 
vector layer, change no data value..).
Let us wait for Roberto's test. I think that it is fixed. Also it is nice to 
reduce time raster display reusing a renderedOp cache mapping.

yeah let's wait. anyway please advice him to use "-v trace" for delivering log 
messages. note that it is not debug but trace which is the most talkative setting.


The "colors" look different because a dem raster, with only one band, is 
painted using a set of grey values between black and white for each cell value. Those 
values are defined by the range of the cell values.  The partial raster generated by the 
extracting tool has, of coarse, a different range of values compared to the original dem. 
That's why the different greys.
It is a way to graphically represent a group of datas (generally elevation but 
also slope values, quantity of rain, insolation, etc) distributed (or better 
reconstructed) as a grid on a surface.
Of course we can change the color schema (via Layer tree, Raster Style) and we 
can omologate two rasters, with different ranges of values to the same color 
schema (saving a color schema of one and importing it into the second, always 
using via Layer tree, Raster Style).

make total sense when explained like that :)


.
Very good job, Ede! I think, if no other problem came from Sextante tools (and 
Roberto agree), this version will be used in the course.

let's wait and see.

homework for you is porting needed functionality from TiffUtils to TiffUtilsV2, 
so that in the end TiffUtils can be removed and only TiffUtilsV2 remains 
essentially wrapping GeoReferencedraster functionality.

..ede


___
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




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


[JPP-Devel] Fwd: [jira] [Commented] (IMAGING-267) Colorful rendering of b/w Monoband TIF

2020-09-22 Thread edgar . soldin

hey Gang,

Gary at Apache-Commons-Imaging has some questions regarding a monoband TIF i 
provided. would one of you with a deeper knowledge of rasters (Peppe, Jukka, 
both?) answer him please in the ticket linked below (you need an account, so 
may have to register, but it's painless and fast).

thanks.. ede


 Forwarded Message 
Subject: [jira] [Commented] (IMAGING-267) Colorful rendering of b/w Monoband TIF
Date: Tue, 22 Sep 2020 00:06:00 + (UTC)
From: Gary Lucas (Jira) 
To: edgar.sol...@web.de


[ 
https://issues.apache.org/jira/browse/IMAGING-267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17199709#comment-17199709
 ]

Gary Lucas commented on IMAGING-267:


Thank you for posting the images. They may help to answer some issues I've 
wondered about for awhile.  I've inspected their content and I have a few 
questions for you.

First off, this TIFF appears to be geophysical data.  But there are no GeoTIFF 
tags bundled with the image. Judging from the ModelTiepointTag, it appears that 
the original image was configured using a projected coordinate system, maybe a 
UTM zone.  It might help me understand this better if there were more location 
information attached to the image. Do you have that information?

Secondly, I note that this TIFF file is not strictly-speaking an image , but is 
actually numerical data stored using the TIFF standard floating-point raster 
format.  My guess is that it's probably elevations. The ability to process TIFF 
files containing floating point data was introduced in the most recent release 
of Commons Imaging.

One challenge of floating point images is how to map the range of values to 
gray scale. In this case, the following text gives the TIFF Tags attached to 
the image:

Directory 0 Has TIFF Image Data, description: Root
 256 (0x100: ImageWidth): 601 (1 Long)
 257 (0x101: ImageLength): 410 (1 Long)
 258 (0x102: BitsPerSample): 32 (1 Short)
 259 (0x103: Compression): 1 (1 Short)
 262 (0x106: PhotometricInterpretation): 1 (Indicates "zero is black")
 277 (0x115: SamplesPerPixel): 1 (1 Short)
 278 (0x116: RowsPerStrip): 8 (1 Long)
 339 (0x153: SampleFormat): 3 (Indicates float-point format)
 33550 (0x830e: ModelPixelScaleTag): 25.0, 25.0 (2 Double)
 33922 (0x8482: ModelTiepointTag): 0.0, 0.0, 0.0, 262846.525725, 4464275.0, 0.0 
(6 Double)
 42113 (0xa481: GDALNoData): 45, 51, 50, 55, 54, 56, 46, 48 (8 Byte)

Upon inspection, I find that the values in the image range from 514 to 2410.  
Commons Imaging does have an API element called the 
custom-photometric-interpreter that lets an application specify how colors (or 
gray tones) are assigned to elevations.  So in this case, I was able to render 
the data by specifying the following lines:

{{ HashMap params = new HashMap<>(); }}
{{ PhotometricInterpreterFloat pi  = }}
{{      new PhotometricInterpreterFloat(514.0f, 2410.0f);}}
{{ params.put(TiffConstants.PARAM_KEY_CUSTOM_PHOTOMETRIC_INTERPRETER, pi);}}
{{ BufferedImage bImage = Imaging.getBufferedImage(target, params);}}
{{ ImageIO.write(bImage, "JPG", output);}}

 


I've attached the image I produced (ISSUE_267.JPG).  However, to create it, I 
had to know before hand what the range of values was.  So my application does a 
few extra steps that I did not show in the example above.  I was wondering how 
the software you used handles this issue.  Is it all automatic?

Also, a second question I had is that the PhotometricInterpretation tag given with your 
image is 1, which means "0 is black".   In other words, the palette should 
range from the darkest shading for the lowest numerical values to the lightest shading 
for the highest values. However, in looking at your image I notice that the lowest value 
pixels are drawn in the lightest colors, which seems to contradict the setting in the 
source TIFF file.  In the image I've attached, the lowest value pixels are draw in the 
darkest colors, which is consistent with the specification in the TIFF image.  Is there 
some setting in the application you used that overwrites the settings from the TIFF file?

!ISSUE_267.JPG!

 


Colorful rendering of b/w Monoband TIF
--

Key: IMAGING-267
URL: https://issues.apache.org/jira/browse/IMAGING-267
Project: Commons Imaging
 Issue Type: Bug
   Reporter: edgar soldin
   Priority: Major
Attachments: ISSUE_267.JPG, mdt25a-commons.png, mdt25a-sextante.png, 
mdt25a.tif


see attached images.
mdt25a.tif - the original tif
mdt25a-commons.png - as rendered/read with Commons Imaging
mdt25a-sextante.png - as rendered /read properly with ImageIO-Core from 
https://github.com/jai-imageio/jai-imageio-core
thanks!.. ede




--
This message was sent by Atlassian Jira
(v8.3.4#803005)


___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net

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

2020-09-22 Thread edgar . soldin



On 9/22/2020 13:49, Giuseppe Aruta wrote:

+       private static ImageAndMetadata readImage(File tiffFile, int 
overviewIndex, int indexStart, Point originalSize,
+           Resolution originalCellSize, Envelope wholeImageEnvelope, Envelope 
viewportEnvelope, double noDataValue,
+           Stats stats) throws IOException, NoninvertibleTransformException {
+
+         ImageInputStream imageInputStream = 
ImageIO.createImageInputStream(tiffFile);
+         Iterator iterator = 
ImageIO.getImageReaders(imageInputStream);


this seems to be a leftover. we want to enforce a specific TIFF reader, which 
seems not to be done here.

why exactly are there two readImage() methods needed anyway? one should 
suffice. can you remove it?

Not sure. As it tries to read overviews of a file from an external .ovr file. I 
have never used or found it in projects. Once I tried to save a tiff with 
overviews using QGIS: I had back two files, a TIF and a OVR one. But when I 
tried to load this  couple into OpenJUMP, it took so long that I gave up. AFAIR 
this was a request of many years ago from someone of the list


why not remove it then, if it's not used or working anyway? if you want to keep 
it, to have a go at it in the future, i'd suggest to at least to deactivate it, 
just to make sure it is no code path used accidentially.

a hack i use sometimes is to add

// explain why!
if (true) throw new java.lang.UnsupportedOperationException();

before some code i want to deactivate. this way the code does not have to be 
commented out and stays readable but will not be used anyway.

..ede


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


[JPP-Devel] SVN: [6516] core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6516
  http://sourceforge.net/p/jump-pilot/code/6516
Author:   ma15569
Date: 2020-09-22 12:06:16 + (Tue, 22 Sep 2020)
Log Message:
---
corrected typo

Modified Paths:
--
core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java

Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 12:04:10 UTC (rev 6515)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 12:06:16 UTC (rev 6516)
@@ -91,7 +91,7 @@
   }
   
   /**
-   * Method to buid an ImageAndMetadata file
+   * Method to build an ImageAndMetadata file
* An ImageAndMetadata groups the Envelope, the Image, the Statistics and 
* NoData value of a TIF file
* @param tiffFile
@@ -203,7 +203,7 @@
  }
 
   /**
-   * Method to read overviews of a TIF
+   * Method to read overviews of a TIF from the file metadata or from an 
external .ovr file
* @param tiffFile
* @param overviewIndex
* @param indexStart
@@ -281,7 +281,7 @@
  }
 
  /**
-  * Method to read Statistics of TIF file (if available) on the file 
itself or
+  * Method to read Statistics of TIF file (if available) from  file 
metadata or
   * from an external aux.xml file
   * @param tiffFile
   * @param noDataValue



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


[JPP-Devel] SVN: [6515] core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6515
  http://sourceforge.net/p/jump-pilot/code/6515
Author:   ma15569
Date: 2020-09-22 12:04:10 + (Tue, 22 Sep 2020)
Log Message:
---
Added comments to Javadoc

Modified Paths:
--
core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java

Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 11:30:56 UTC (rev 6514)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 12:04:10 UTC (rev 6515)
@@ -89,6 +89,23 @@
 renderedOp = JAI.create("scale", parameterBlock);
 return JAI.create("scale", parameterBlock);
   }
+  
+  /**
+   * Method to buid an ImageAndMetadata file
+   * An ImageAndMetadata groups the Envelope, the Image, the Statistics and 
+   * NoData value of a TIF file
+   * @param tiffFile
+   * @param viewportEnvelope
+   * @param requestedRes
+   * @param overviews
+   * @param stats
+   * @return ImageAndMetadata
+   * @throws NoninvertibleTransformException
+   * @throws IOException
+   * @throws FileNotFoundException
+   * @throws TiffTags.TiffReadingException
+   * @throws Exception
+   */
   public static ImageAndMetadata readImage(File tiffFile, Envelope 
viewportEnvelope, Resolution requestedRes,
  Overviews overviews, Stats stats) throws 
NoninvertibleTransformException, IOException, FileNotFoundException,
  TiffTags.TiffReadingException, Exception {
@@ -101,14 +118,16 @@
Double noData = tiffMetadata.getNoData();
 
// Now try with tfw
-   if (cellSize == null) {
+/*   if (cellSize == null) {
  WorldFileHandler worldFileHandler = new 
WorldFileHandler(tiffFile.getAbsolutePath(), true);
  Envelope envelope = 
worldFileHandler.readWorldFile(originalImageWidth, originalImageHeight);
  cellSize = new Resolution(envelope.getWidth() / 
originalImageWidth, envelope.getHeight() / originalImageHeight);
-   }
+   }*/
 
-   Envelope wholeImageEnvelope = 
RasterImageIO.getGeoReferencing(tiffFile.getAbsolutePath(), true,
-   new Point(originalImageWidth, originalImageHeight));
+   Envelope wholeImageEnvelope = getEnvelope(tiffFile);
+   
+   
//RasterImageIO.getGeoReferencing(tiffFile.getAbsolutePath(), true,
+  // new Point(originalImageWidth, originalImageHeight));
 
if (requestedRes == null) {
  requestedRes = cellSize;
@@ -183,6 +202,21 @@
 
  }
 
+  /**
+   * Method to read overviews of a TIF
+   * @param tiffFile
+   * @param overviewIndex
+   * @param indexStart
+   * @param originalSize
+   * @param originalCellSize
+   * @param wholeImageEnvelope
+   * @param viewportEnvelope
+   * @param noDataValue
+   * @param stats
+   * @return
+   * @throws IOException
+   * @throws NoninvertibleTransformException
+   */
  private static ImageAndMetadata readImage(File tiffFile, int 
overviewIndex, int indexStart, Point originalSize,
  Resolution originalCellSize, Envelope wholeImageEnvelope, 
Envelope viewportEnvelope, double noDataValue,
  Stats stats) throws IOException, NoninvertibleTransformException {
@@ -246,6 +280,19 @@
 
  }
 
+ /**
+  * Method to read Statistics of TIF file (if available) on the file 
itself or
+  * from an external aux.xml file
+  * @param tiffFile
+  * @param noDataValue
+  * @param imageFile
+  * @return
+  * @throws ParserConfigurationException
+  * @throws TransformerException
+  * @throws ImageReadException
+  * @throws IOException
+  * @throws SAXException
+  */
  private static Stats calculateStats(File tiffFile, double 
noDataValue, File imageFile)
  throws ParserConfigurationException, TransformerException, 
ImageReadException, IOException, SAXException {
 
@@ -286,7 +333,18 @@
return createStatsXml(tiffFile, noDataValue, auxXmlFile);
 
  }
-
+  /**
+   * Method to compute statistic of a TIF file and write as aux.xml file
+   * @param tiffFile
+   * @param noDataValue
+   * @param auxXmlFile
+   * @return
+   * @throws ParserConfigurationException
+   * @throws TransformerException
+   * @throws TransformerConfigurationException
+   * @throws SAXException
+   * @throws IOException
+   */
  private static Stats createStatsXml(File tiffFile, double 
noDataValue, File auxXmlFile)
  throws ParserConfigurationException, TransformerException, 
TransformerConfigurationException, SAXException,
  IOException {
@@ -363,6 +421,15 @@
 
  }
 
+ /**
+  * Method to read the value of a cell at defined position on the 

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

2020-09-22 Thread Giuseppe Aruta
*we already have support for reading
GeoReferencedRaster.parseGDALM**etaData(URI
uri) (seems format agnostic too). but that is depending on GDAL installed,
while the implementaion in TiffUtils.calculateStats() seems be plain java
utilizing some apache commons imaging code but is limited to TIFF files*.

Note that, together with Statistics, also NoData value is read using apache
commons. Possibly it can be used JAI staff instead (as in
AddRasterImageLayerWizard class).


Il giorno mar 22 set 2020 alle ore 13:49 Giuseppe Aruta <
giuseppe.ar...@gmail.com> ha scritto:

> > +   private static ImageAndMetadata readImage(File tiffFile, int
> overviewIndex, int indexStart, Point originalSize,
> > +   Resolution originalCellSize, Envelope wholeImageEnvelope,
> Envelope viewportEnvelope, double noDataValue,
> > +   Stats stats) throws IOException,
> NoninvertibleTransformException {
> > +
> > + ImageInputStream imageInputStream =
> ImageIO.createImageInputStream(tiffFile);
> > + Iterator iterator =
> ImageIO.getImageReaders(imageInputStream);
>
> this seems to be a leftover. we want to enforce a specific TIFF reader,
> which seems not to be done here.
>
> why exactly are there two readImage() methods needed anyway? one should
> suffice. can you remove it?
>
> Not sure. As it tries to read overviews of a file from an external .ovr
> file. I have never used or found it in projects. Once I tried to save a
> tiff with overviews using QGIS: I had back two files, a TIF and a OVR one.
> But when I tried to load this  couple into OpenJUMP, it took so long that I
> gave up. AFAIR this was a request of many years ago from someone of the list
>
> Il giorno mar 22 set 2020 alle ore 13:07  ha scritto:
>
>> we already have support for reading
>> GeoReferencedRaster.parseGDALMetaData(URI uri) (seems format agnostic too).
>> but that is depending on GDAL installed, while the implementaion in
>> TiffUtils.calculateStats() seems be plain java utilizing some apache
>> commons imaging code but is limited to TIFF files.
>>
>> note the following comment in GeoRefRaster
>>/**
>> * initialize the img and try to parse geo infos via (in this order)
>> * worldfile, gdal or geotiff
>> */
>>protected void readRasterfile() throws ReferencedImageException {
>>
>> tl;dr i am good with keeping the addtional metadata reading within
>> TiffUtils generally. still you my want to consider a caching approach there
>> as well if the info is accessed more than once and expected not to change
>> over the course of the runtime.
>>
>> ..ede
>>
>> On 9/22/2020 12:32, Giuseppe Aruta wrote:
>> > I will make those changes. Statistics are calculated in order to reuse
>> on raster analysis (sextante). It is also saved into a special .aux.xml
>> sidecar file.
>> > At this moment there is no need to implement GeoReferencedRaster with
>> Statistic read as it is uìused only by Sextante.
>> >
>> > Il giorno mar 22 set 2020 alle ore 11:59 > edgar.sol...@web.de>> ha scritto:
>> >
>> > hey Peppe,
>> >
>> > nice try, but no dice. the reason i created an explicit TiffUtilsV2
>> was
>> > to make sure it contains no reference to RasterImageIO or TiffTags
>> > anymore. the idea is to wrap GeoReferencedRaster functionality to
>> reuse.
>> > GeoReferencedRaster includes all functionality for retrieving an
>> > Envelope or dimensions needed.
>> >
>> > If you are lacking functionality in GeoReferencedRaster we may add
>> it
>> > accordingly.
>> >
>> > i cut some code parts below and commented them which should be
>> replaced
>> > by using GeoReferencedRaster routines. ..ede
>> >
>> >
>> >
>> > On 9/22/2020 11:26, jump-pilot-svn--- via Jump-pilot-devel wrote:
>> >  > Revision: 6507
>> >  > http://sourceforge.net/p/jump-pilot/code/6507 <
>> http://sourceforge.net/p/jump-pilot/code/6507>
>> >  > Author:   ma15569
>> >  > Date: 2020-09-22 09:26:19 + (Tue, 22 Sep 2020)
>> >  > Log Message:
>> >  > ---
>> >  > Ported functionality from TiffUtils to TiffUtilsV2.
>> >  > Make TiffUtils deprecated
>> >  >
>> > SNIP
>>
>>
>>
>>
>> ___
>> 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: [6507] core/trunk/src/org/openjump/core/rasterimage

2020-09-22 Thread Giuseppe Aruta
> +   private static ImageAndMetadata readImage(File tiffFile, int
overviewIndex, int indexStart, Point originalSize,
> +   Resolution originalCellSize, Envelope wholeImageEnvelope,
Envelope viewportEnvelope, double noDataValue,
> +   Stats stats) throws IOException,
NoninvertibleTransformException {
> +
> + ImageInputStream imageInputStream =
ImageIO.createImageInputStream(tiffFile);
> + Iterator iterator =
ImageIO.getImageReaders(imageInputStream);

this seems to be a leftover. we want to enforce a specific TIFF reader,
which seems not to be done here.

why exactly are there two readImage() methods needed anyway? one should
suffice. can you remove it?

Not sure. As it tries to read overviews of a file from an external .ovr
file. I have never used or found it in projects. Once I tried to save a
tiff with overviews using QGIS: I had back two files, a TIF and a OVR one.
But when I tried to load this  couple into OpenJUMP, it took so long that I
gave up. AFAIR this was a request of many years ago from someone of the list

Il giorno mar 22 set 2020 alle ore 13:07  ha scritto:

> we already have support for reading
> GeoReferencedRaster.parseGDALMetaData(URI uri) (seems format agnostic too).
> but that is depending on GDAL installed, while the implementaion in
> TiffUtils.calculateStats() seems be plain java utilizing some apache
> commons imaging code but is limited to TIFF files.
>
> note the following comment in GeoRefRaster
>/**
> * initialize the img and try to parse geo infos via (in this order)
> * worldfile, gdal or geotiff
> */
>protected void readRasterfile() throws ReferencedImageException {
>
> tl;dr i am good with keeping the addtional metadata reading within
> TiffUtils generally. still you my want to consider a caching approach there
> as well if the info is accessed more than once and expected not to change
> over the course of the runtime.
>
> ..ede
>
> On 9/22/2020 12:32, Giuseppe Aruta wrote:
> > I will make those changes. Statistics are calculated in order to reuse
> on raster analysis (sextante). It is also saved into a special .aux.xml
> sidecar file.
> > At this moment there is no need to implement GeoReferencedRaster with
> Statistic read as it is uìused only by Sextante.
> >
> > Il giorno mar 22 set 2020 alle ore 11:59  edgar.sol...@web.de>> ha scritto:
> >
> > hey Peppe,
> >
> > nice try, but no dice. the reason i created an explicit TiffUtilsV2
> was
> > to make sure it contains no reference to RasterImageIO or TiffTags
> > anymore. the idea is to wrap GeoReferencedRaster functionality to
> reuse.
> > GeoReferencedRaster includes all functionality for retrieving an
> > Envelope or dimensions needed.
> >
> > If you are lacking functionality in GeoReferencedRaster we may add it
> > accordingly.
> >
> > i cut some code parts below and commented them which should be
> replaced
> > by using GeoReferencedRaster routines. ..ede
> >
> >
> >
> > On 9/22/2020 11:26, jump-pilot-svn--- via Jump-pilot-devel wrote:
> >  > Revision: 6507
> >  > http://sourceforge.net/p/jump-pilot/code/6507 <
> http://sourceforge.net/p/jump-pilot/code/6507>
> >  > Author:   ma15569
> >  > Date: 2020-09-22 09:26:19 + (Tue, 22 Sep 2020)
> >  > Log Message:
> >  > ---
> >  > Ported functionality from TiffUtils to TiffUtilsV2.
> >  > Make TiffUtils deprecated
> >  >
> > SNIP
>
>
>
>
> ___
> 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


[JPP-Devel] SVN: [6514] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6514
  http://sourceforge.net/p/jump-pilot/code/6514
Author:   edso
Date: 2020-09-22 11:30:56 + (Tue, 22 Sep 2020)
Log Message:
---
reformatted from mixed space/tabs to spaces only/tabwidth 2 spaces

Modified Paths:
--
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java

Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
===
--- core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 11:26:31 UTC (rev 6513)
+++ core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 11:30:56 UTC (rev 6514)
@@ -6,7 +6,6 @@
 
 package org.openjump.sigle.utilities.geom;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -27,177 +26,170 @@
 import com.vividsolutions.jump.workbench.Logger;
 
 /**
- * This class can check if a FeatureCollection has only one Geometry Type
- * and in this case, return this Geometry Type.
+ * This class can check if a FeatureCollection has only one Geometry Type and 
in
+ * this case, return this Geometry Type.
  *
- * @author Erwan Bocher 
+ * @author Erwan Bocher
  * @author Olivier Bedel
  * @version 2005-08-10
- * @author Giuseppe Aruta [2020-07-22]
- * added two method to valid and to union by attribute a FeatureCollection
+ * @author Giuseppe Aruta [2020-07-22] added two method to valid and to union 
by
+ * attribute a FeatureCollection
  */
 
 public class FeatureCollectionUtil {
 
-
-   // renvoie la dimension des entites de la featureCollection fc :
-   // 0 pour si fc ne contient que des entites ponctuelles
-   // 1 pour si fc ne contient que des entites lineaires
-   // 2 pour si fc ne contient que des entites surfaciques
-   // -1 si fc ne contient aucune entite, ou si elle contient des entites 
-   // ayant des dimensions differentes
-   
-   public static int getFeatureCollectionDimension(FeatureCollection fc) {
-   int type = -1;  // type des geometry des entites de la 
featurecollection
-   // -1 correspond au type complexe 
-   // (plusieurs dimensions de geometry 
dans la meme featureCollection) 
-   
-   if (fc.getFeatures().size()>0) {
-   Iterator i = fc.getFeatures().iterator();
-   
-   // initialisation des la variable type
-   Feature f = (Feature) i.next();
-   type = f.getGeometry().getDimension();
-   // cas particulier des geometryCollection
-   if (f.getGeometry() instanceof GeometryCollection) {
-   GeometryCollection geomCol = (GeometryCollection) 
f.getGeometry();
-   // on ne prend en compte que les geometryCollection non 
specialisees, ie pas les
-   // multipoint, multilinstring ou multipolygon
-   if 
(geomCol.getGeometryType().equalsIgnoreCase("GeometryCollection"))
-   type = -1; 
-   }
-   
-   
-   // on parcourt le reste des entites de la featureCollection
-   while (i.hasNext() && type !=-1) {
-   f = (Feature) i.next();
-   // si la geometrie de f est complexe, on marque le type 
comme complexe
-   if (f.getGeometry() instanceof GeometryCollection) {
-   GeometryCollection geomCol = (GeometryCollection) 
f.getGeometry();
-   if 
(geomCol.getGeometryType().equalsIgnoreCase("GeometryCollection"))
-   type = -1; 
-   }
-   // si sa dimension ne correspond pas au
-   // type precedent, on marque le type comme complexe
-   if  (f.getGeometry().getDimension() != type) 
-   type = -1;
-   }
-   }
-   
-   return type;
-   }
-   
-   public static ArrayList getAttributesList(FeatureCollection fc) {
-   
-   ArrayList AttributesList = new ArrayList();
-   FeatureSchema fs = fc.getFeatureSchema();
-   
-   
-   for (int i=0; ihttps://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
-*  for the complete list).
-* 
-* This method should be applied before merging features via
-* {@link #unionByAttributeValue(FeatureCollection, String)
-* because not simple geometries will be not processed
-* 
-* @param FeatureCollection fc
-*/
-   public static void validFeatureCollection(FeatureCollection fc) {
-   MakeValidOp makeValidOp = new MakeValidOp();

Re: [JPP-Devel] SVN: [6513] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread Giuseppe Aruta
OK

2020-09-22 13:28 GMT+02:00, edgar.sol...@web.de :
> Peppe,
>
> just rephrased/formatted/typofixed some more. can you check that it
> describes what is done? ..thx ede
>
> On 9/22/2020 13:26, jump-pilot-svn--- via Jump-pilot-devel wrote:
>> Revision: 6513
>>http://sourceforge.net/p/jump-pilot/code/6513
>> Author:   edso
>> Date: 2020-09-22 11:26:31 + (Tue, 22 Sep 2020)
>> Log Message:
>> ---
>> some rephrasing/formatting
>>
>> Modified Paths:
>> --
>>
>> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
>>
>> Modified:
>> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
>> ===
>> ---
>> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java  
>> 2020-09-22
>> 10:25:35 UTC (rev 6512)
>> +++
>> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java  
>> 2020-09-22
>> 11:26:31 UTC (rev 6513)
>> @@ -105,15 +105,18 @@
>>  /**
>>   * Method to make valid all the geometries of a 
>> FeatureCollection
>>   * using the class MakeValidOp.
>> + *
>>   * A geometry is not valid if it is not simple:
>> - * This condition occurs when any of the following conditions 
>> are
>> true:
>> - * Incorrect ring orientation (polygon), self-intersection rings
>> (polygon)
>> - * self-intersection path (polyline), unclosed ring (polygon)
>> - * (see also
>> https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
>> - * for the complete list).
>> - * This method should be applied before merge feature
>> - * [see method unionByAttributeValue(FeatureCollection
>> featureCollection, String attrbuteName)]
>> - * as not simple geometries will be not processed
>> + *  This condition occurs when any of the following conditions 
>> are
>> true:
>> + *  Incorrect ring orientation (polygon), self-intersection 
>> rings
>> (polygon)
>> + *  self-intersection path (polyline), unclosed ring (polygon)
>> + *  (see also
>> https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
>> + *  for the complete list).
>> + *
>> + * This method should be applied before merging features via
>> + * {@link #unionByAttributeValue(FeatureCollection, String)
>> + * because not simple geometries will be not processed
>> + *
>>   * @param FeatureCollection fc
>>   */
>>  public static void validFeatureCollection(FeatureCollection fc) 
>> {
>> @@ -128,13 +131,14 @@
>> }
>>  
>>  /**
>> - * Mathod to merge geometries of a FeaureCollection according
>> - * to the values of an attribute name
>> + * Merge features and their geometries in the FeatureCollection
>> given
>> + * when the given attribute name contains identical values
>> + *
>>   * @param FeatureCollection fc
>> - * @param String attrbuteName
>> + * @param String attributeName
>>   * @throws Exception
>>   */
>> - public static void unionByAttributeValue(FeatureCollection
>> featureCollection, String attrbuteName) throws Exception {
>> + public static void unionByAttributeValue(FeatureCollection
>> featureCollection, String attributeName) throws Exception {
>>FeatureSchema schema = 
>> featureCollection.getFeatureSchema();
>>if (featureCollection.getFeatures().size() > 1 &&
>>  
>> featureCollection.getFeatures().get(0).getGeometry() !=
>> null) {
>> @@ -149,7 +153,7 @@
>>  newSchema = schema;
>>  Map map = new HashMap> FeatureCollection>();
>>  for (Feature feature  : featureCollection.getFeatures())
>> {
>> - Object key = feature.getAttribute(attrbuteName);
>> + Object key = feature.getAttribute(attributeName);
>>   if (!map.containsKey(key)) {
>>   FeatureCollection fd = new
>> FeatureDataset(featureCollection.getFeatureSchema());
>>   fd.add(feature);
>> @@ -164,7 +168,7 @@
>>  FeatureCollection fca = map.get(key);
>>  if (fca.size() > 0) {
>>Feature feature = union(fca);
>> -  feature.setAttribute(attrbuteName, key);
>> +  feature.setAttribute(attributeName, key);
>>Feature newFeature = new
>> 

Re: [JPP-Devel] SVN: [6513] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread edgar . soldin

Peppe,

just rephrased/formatted/typofixed some more. can you check that it describes 
what is done? ..thx ede

On 9/22/2020 13:26, jump-pilot-svn--- via Jump-pilot-devel wrote:

Revision: 6513
   http://sourceforge.net/p/jump-pilot/code/6513
Author:   edso
Date: 2020-09-22 11:26:31 + (Tue, 22 Sep 2020)
Log Message:
---
some rephrasing/formatting

Modified Paths:
--
 core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java

Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
===
--- core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 10:25:35 UTC (rev 6512)
+++ core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 11:26:31 UTC (rev 6513)
@@ -105,15 +105,18 @@
/**
 * Method to make valid all the geometries of a FeatureCollection
 * using the class MakeValidOp.
+*
 * A geometry is not valid if it is not simple:
-* This condition occurs when any of the following conditions are true:
-* Incorrect ring orientation (polygon), self-intersection rings 
(polygon)
-* self-intersection path (polyline), unclosed ring (polygon)
-* (see also 
https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
-* for the complete list).
-* This method should be applied before merge feature
-* [see method unionByAttributeValue(FeatureCollection 
featureCollection, String attrbuteName)]
-* as not simple geometries will be not processed
+*  This condition occurs when any of the following conditions are true:
+*  Incorrect ring orientation (polygon), self-intersection rings 
(polygon)
+*  self-intersection path (polyline), unclosed ring (polygon)
+*  (see also 
https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
+*  for the complete list).
+*
+* This method should be applied before merging features via
+* {@link #unionByAttributeValue(FeatureCollection, String)
+* because not simple geometries will be not processed
+*
 * @param FeatureCollection fc
 */
public static void validFeatureCollection(FeatureCollection fc) {
@@ -128,13 +131,14 @@
   }

/**
-* Mathod to merge geometries of a FeaureCollection according
-* to the values of an attribute name
+* Merge features and their geometries in the FeatureCollection given
+* when the given attribute name contains identical values
+*
 * @param FeatureCollection fc
-* @param String attrbuteName
+* @param String attributeName
 * @throws Exception
 */
-public static void unionByAttributeValue(FeatureCollection 
featureCollection, String attrbuteName) throws Exception {
+public static void unionByAttributeValue(FeatureCollection 
featureCollection, String attributeName) throws Exception {
  FeatureSchema schema = featureCollection.getFeatureSchema();
  if (featureCollection.getFeatures().size() > 1 &&

featureCollection.getFeatures().get(0).getGeometry() != null) {
@@ -149,7 +153,7 @@
newSchema = schema;
Map map = new HashMap();
for (Feature feature  : featureCollection.getFeatures()) {
-Object key = feature.getAttribute(attrbuteName);
+Object key = feature.getAttribute(attributeName);
 if (!map.containsKey(key)) {
 FeatureCollection fd = new 
FeatureDataset(featureCollection.getFeatureSchema());
 fd.add(feature);
@@ -164,7 +168,7 @@
FeatureCollection fca = map.get(key);
if (fca.size() > 0) {
  Feature feature = union(fca);
- feature.setAttribute(attrbuteName, key);
+ feature.setAttribute(attributeName, key);
  Feature newFeature = new BasicFeature(newSchema);
// Copy feature attributes in newFeature
  for (int j = 0, max = newSchema.getAttributeCount() ; j 
< max ; j++) {



___
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


[JPP-Devel] SVN: [6513] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6513
  http://sourceforge.net/p/jump-pilot/code/6513
Author:   edso
Date: 2020-09-22 11:26:31 + (Tue, 22 Sep 2020)
Log Message:
---
some rephrasing/formatting

Modified Paths:
--
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java

Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
===
--- core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 10:25:35 UTC (rev 6512)
+++ core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 11:26:31 UTC (rev 6513)
@@ -105,15 +105,18 @@
/**
 * Method to make valid all the geometries of a FeatureCollection
 * using the class MakeValidOp.
+* 
 * A geometry is not valid if it is not simple:
-* This condition occurs when any of the following conditions are true:
-* Incorrect ring orientation (polygon), self-intersection rings 
(polygon)
-* self-intersection path (polyline), unclosed ring (polygon)
-* (see also 
https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
-* for the complete list).
-* This method should be applied before merge feature
-* [see method unionByAttributeValue(FeatureCollection 
featureCollection, String attrbuteName)]
-* as not simple geometries will be not processed
+*  This condition occurs when any of the following conditions are true:
+*  Incorrect ring orientation (polygon), self-intersection rings 
(polygon)
+*  self-intersection path (polyline), unclosed ring (polygon)
+*  (see also 
https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
+*  for the complete list).
+* 
+* This method should be applied before merging features via
+* {@link #unionByAttributeValue(FeatureCollection, String)
+* because not simple geometries will be not processed
+* 
 * @param FeatureCollection fc
 */
public static void validFeatureCollection(FeatureCollection fc) {
@@ -128,13 +131,14 @@
   }

/**
-* Mathod to merge geometries of a FeaureCollection according
-* to the values of an attribute name
+* Merge features and their geometries in the FeatureCollection given 
+* when the given attribute name contains identical values
+* 
 * @param FeatureCollection fc
-* @param String attrbuteName
+* @param String attributeName
 * @throws Exception
 */
-public static void unionByAttributeValue(FeatureCollection 
featureCollection, String attrbuteName) throws Exception {
+public static void unionByAttributeValue(FeatureCollection 
featureCollection, String attributeName) throws Exception {
  FeatureSchema schema = featureCollection.getFeatureSchema();
  if (featureCollection.getFeatures().size() > 1 &&

featureCollection.getFeatures().get(0).getGeometry() != null) {
@@ -149,7 +153,7 @@
newSchema = schema;
Map map = new HashMap();
for (Feature feature  : featureCollection.getFeatures()) {
-Object key = feature.getAttribute(attrbuteName);
+Object key = feature.getAttribute(attributeName);
 if (!map.containsKey(key)) {
 FeatureCollection fd = new 
FeatureDataset(featureCollection.getFeatureSchema());
 fd.add(feature);
@@ -164,7 +168,7 @@
FeatureCollection fca = map.get(key);
if (fca.size() > 0) {
  Feature feature = union(fca);
- feature.setAttribute(attrbuteName, key);
+ feature.setAttribute(attributeName, key);
  Feature newFeature = new BasicFeature(newSchema);
// Copy feature attributes in newFeature
  for (int j = 0, max = newSchema.getAttributeCount() ; 
j < max ; j++) {



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


Re: [JPP-Devel] SVN: [6508] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread Giuseppe Aruta
com.vividsolutions.jump.util.CollectionUtil seemed to me too generic to add
these method. The only class I found that could have been used was Sigle one

Il giorno mar 22 set 2020 alle ore 13:17  ha scritto:

> any specific reason why you added it to the class in the sigle package?
> ..ede
>
> On 9/22/2020 12:25, Giuseppe Aruta wrote:
> > Done
> >
> > Il giorno mar 22 set 2020 alle ore 12:06  edgar.sol...@web.de>> ha scritto:
> >
> > Peppe, some comments inline below ..ede
> >
> > On 9/22/2020 11:30, jump-pilot-svn--- via Jump-pilot-devel wrote:
> >  > Revision: 6508
> >  > http://sourceforge.net/p/jump-pilot/code/6508 <
> http://sourceforge.net/p/jump-pilot/code/6508>
> >  > Author:   ma15569
> >  > Date: 2020-09-22 09:30:06 + (Tue, 22 Sep 2020)
> >  > Log Message:
> >  > ---
> >  > added two method to valid and to union by attribute a
> FeatureCollection
> >  >
> >  > Modified Paths:
> >  > --
> >  >
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
> >  >
> >  > Modified:
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
> >  >
> ===
> >  > ---
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
>  2020-09-22 09:26:19 UTC (rev 6507)
> >  > +++
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
>  2020-09-22 09:30:06 UTC (rev 6508)
> >  > @@ -8,12 +8,23 @@
> >  >
> >  >
> > SNIP
> >  >
> >  >   /**
> >  >* This class can check if a FeatureCollection has only one
> Geometry Type
> >  > @@ -22,7 +33,8 @@
> >  >* @author Erwan Bocher
> >  >* @author Olivier Bedel
> >  >* @version 2005-08-10
> >  > - *
> >  > + * @author Giuseppe Aruta [2020-07-22]
> >  > + * added two method to valid and to union by attribute a
> FeatureCollection
> >  >*/
> >  >
> >  >   public class FeatureCollectionUtil {
> >  > @@ -90,4 +102,88 @@
> >  >   return AttributesList;
> >  >
> >  >   }
> >  > + /**
> >  > +  * Method to make a FeatureCollection valid
> >  > +  * @param fc
> >  > +  */
> >
> > can you add to the javadoc exactly what is the method doing to make
> it valid? why wasn't it valid before?
> >
> >  > + public static void
> validFeatureCollection(FeatureCollection fc) {
> >  > + MakeValidOp makeValidOp = new MakeValidOp();
> >  > +  makeValidOp.setPreserveGeomDim(true);
> >  > +  makeValidOp.setPreserveDuplicateCoord(false);
> >  > +  for (Feature feature  : fc.getFeatures()) {
> >  > +   Geometry validGeom =
> makeValidOp.makeValid(feature.getGeometry());
> >  > +   feature.setGeometry(validGeom);
> >  > + }
> >  > +   // return fc;
> >  > +}
> >  > +
> >  > + /**
> >  > +  * Mathod to merge geometries of a FeaureCollection
> according
> >
> > probably "Method to merge geometries of a FeatureCollection
> according"
> >
> >  > +  * to an attribute
> >  > +  * @param featureCollection
> >  > +  * @param value
> >
> > what is the value. looks like the attribute name to me. please
> javadoc it
> >
> >  > +  * @throws Exception
> >  > +  */
> >  > +  public static void
> unionByAttributeValue(FeatureCollection featureCollection, String value)
> throws Exception {
> >  > +   FeatureSchema schema =
> featureCollection.getFeatureSchema();
> >  > +   if (featureCollection.getFeatures().size() >
> 1 &&
> >  > +
>  featureCollection.getFeatures().get(0).getGeometry() != null) {
> >  > +
>  featureCollection.getFeatures().get(0).getGeometry().getFactory();
> >  > + }
> >  > + else {
> >  > + Logger.error(
> >  > +
>  I18N.get("ui.plugin.analysis.DissolvePlugIn.needs-two-features-or-more"));
> >  > +   // return null;
> >  > + }
> >  > + FeatureSchema newSchema;
> >  > + newSchema = schema;
> >  > + Map map = new
> HashMap();
> >  > + for (Feature feature  :
> featureCollection.getFeatures()) {
> >  > +  Object key =
> feature.getAttribute(value);
> >  > +  if (!map.containsKey(key)) {
> >  > +  FeatureCollection fd = new
> FeatureDataset(featureCollection.getFeatureSchema());
> >  

Re: [JPP-Devel] SVN: [6508] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread edgar . soldin

any specific reason why you added it to the class in the sigle package? ..ede

On 9/22/2020 12:25, Giuseppe Aruta wrote:

Done

Il giorno mar 22 set 2020 alle ore 12:06 mailto:edgar.sol...@web.de>> ha scritto:

Peppe, some comments inline below ..ede

On 9/22/2020 11:30, jump-pilot-svn--- via Jump-pilot-devel wrote:
 > Revision: 6508
 > http://sourceforge.net/p/jump-pilot/code/6508 

 > Author:   ma15569
 > Date:     2020-09-22 09:30:06 + (Tue, 22 Sep 2020)
 > Log Message:
 > ---
 > added two method to valid and to union by attribute a FeatureCollection
 >
 > Modified Paths:
 > --
 >      
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
 >
 > Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
 > ===
 > --- 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java       
2020-09-22 09:26:19 UTC (rev 6507)
 > +++ 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java       
2020-09-22 09:30:06 UTC (rev 6508)
 > @@ -8,12 +8,23 @@
 >
 >
SNIP
 >
 >   /**
 >    * This class can check if a FeatureCollection has only one Geometry 
Type
 > @@ -22,7 +33,8 @@
 >    * @author Erwan Bocher
 >    * @author Olivier Bedel
 >    * @version 2005-08-10
 > - *
 > + * @author Giuseppe Aruta [2020-07-22]
 > + * added two method to valid and to union by attribute a 
FeatureCollection
 >    */
 >
 >   public class FeatureCollectionUtil {
 > @@ -90,4 +102,88 @@
 >                       return AttributesList;
 >
 >   }
 > +     /**
 > +      * Method to make a FeatureCollection valid
 > +      * @param fc
 > +      */

can you add to the javadoc exactly what is the method doing to make it 
valid? why wasn't it valid before?

 > +             public static void 
validFeatureCollection(FeatureCollection fc) {
 > +                     MakeValidOp makeValidOp = new MakeValidOp();
 > +                      makeValidOp.setPreserveGeomDim(true);
 > +                  makeValidOp.setPreserveDuplicateCoord(false);
 > +                  for (Feature feature  : fc.getFeatures()) {
 > +                       Geometry validGeom = 
makeValidOp.makeValid(feature.getGeometry());
 > +                       feature.setGeometry(validGeom);
 > +                     }
 > +               // return fc;
 > +                }
 > +
 > +             /**
 > +              * Mathod to merge geometries of a FeaureCollection 
according

probably "Method to merge geometries of a FeatureCollection according"

 > +              * to an attribute
 > +              * @param featureCollection
 > +              * @param value

what is the value. looks like the attribute name to me. please javadoc it

 > +              * @throws Exception
 > +              */
 > +              public static void 
unionByAttributeValue(FeatureCollection featureCollection, String value) throws 
Exception {
 > +                       FeatureSchema schema = 
featureCollection.getFeatureSchema();
 > +                   if (featureCollection.getFeatures().size() > 1 &&
 > +                                     
featureCollection.getFeatures().get(0).getGeometry() != null) {
 > +                             
featureCollection.getFeatures().get(0).getGeometry().getFactory();
 > +                     }
 > +                     else {
 > +                             Logger.error(
 > +                                 
I18N.get("ui.plugin.analysis.DissolvePlugIn.needs-two-features-or-more"));
 > +                       // return null;
 > +                     }
 > +                     FeatureSchema newSchema;
 > +                         newSchema = schema;
 > +                     Map map = new 
HashMap();
 > +                     for (Feature feature  : 
featureCollection.getFeatures()) {
 > +                          Object key = feature.getAttribute(value);
 > +                          if (!map.containsKey(key)) {
 > +                              FeatureCollection fd = new 
FeatureDataset(featureCollection.getFeatureSchema());
 > +                              fd.add(feature);
 > +                              map.put(key, fd);
 > +                          }  else {
 > +                              map.get(key).add(feature);
 > +                          }
 > +                      }
 > +                     
featureCollection.removeAll(featureCollection.getFeatures());
 > +                         for (Iterator i = 
map.keySet().iterator() ; i.hasNext() ; ) {
 > +                             

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

2020-09-22 Thread edgar . soldin

we already have support for reading GeoReferencedRaster.parseGDALMetaData(URI 
uri) (seems format agnostic too). but that is depending on GDAL installed, 
while the implementaion in TiffUtils.calculateStats() seems be plain java 
utilizing some apache commons imaging code but is limited to TIFF files.

note the following comment in GeoRefRaster
  /**
   * initialize the img and try to parse geo infos via (in this order)
   * worldfile, gdal or geotiff
   */
  protected void readRasterfile() throws ReferencedImageException {

tl;dr i am good with keeping the addtional metadata reading within TiffUtils 
generally. still you my want to consider a caching approach there as well if 
the info is accessed more than once and expected not to change over the course 
of the runtime.

..ede

On 9/22/2020 12:32, Giuseppe Aruta wrote:

I will make those changes. Statistics are calculated in order to reuse on 
raster analysis (sextante). It is also saved into a special .aux.xml sidecar 
file.
At this moment there is no need to implement GeoReferencedRaster with Statistic 
read as it is uìused only by Sextante.

Il giorno mar 22 set 2020 alle ore 11:59 mailto:edgar.sol...@web.de>> ha scritto:

hey Peppe,

nice try, but no dice. the reason i created an explicit TiffUtilsV2 was
to make sure it contains no reference to RasterImageIO or TiffTags
anymore. the idea is to wrap GeoReferencedRaster functionality to reuse.
GeoReferencedRaster includes all functionality for retrieving an
Envelope or dimensions needed.

If you are lacking functionality in GeoReferencedRaster we may add it
accordingly.

i cut some code parts below and commented them which should be replaced
by using GeoReferencedRaster routines. ..ede



On 9/22/2020 11:26, jump-pilot-svn--- via Jump-pilot-devel wrote:
 > Revision: 6507
 > http://sourceforge.net/p/jump-pilot/code/6507 

 > Author:   ma15569
 > Date:     2020-09-22 09:26:19 + (Tue, 22 Sep 2020)
 > Log Message:
 > ---
 > Ported functionality from TiffUtils to TiffUtilsV2.
 > Make TiffUtils deprecated
 >
SNIP





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


[JPP-Devel] New tool to rasterize vectors

2020-09-22 Thread Giuseppe Aruta
Hi all,
Roberto Rossi and I made a revision on Rasterize vector layer tools in
OpenJUMP.
This functionality is quite essential in raster analysis as it allows to
transfer info in a raster to reuse in so-called Raster algebra to get new
information.
Generally, in a raster analysis, the number of vector files that can be
transformed into rasters can be huge. So the user  needs a fast and exact
rasterization tool

OpenJUMP currently has two tools: one on sextante toolbox and the other on
OpenKLEM plugin.

a) The one of OpenKLEM is quite exact on transformation but it takes a
quite long time to convert a vector file to a raster. In a test, using a
layer with 6000 polygons, this tool takes almost 4 to 5 minutes. It is not
acceptable if the user needs to convert many layers.

b) The tool in Sextante is very fast, basically 6 to 7 seconds for a layer
of 6000 polygons. The problem of this tool is that it requires that the
vector layer should be first validated to correct non simple geometries and
then the geometries must be merged according to common values from an
attribute name. The second (merge) is sequential to the first (validate).
All those three processes (Validate, Merge and Rasterize) are located into
different plugins between OJ and Sextante. Using all to rasterize a vector
will enlarge the time and actions and it will again not be acceptable if
the files to convert are many.

In order to solve this problem, I developed a Raterization plugin for
OpenJUMP, mostly reusing Sextante code but adding also the other
preprocesses (Validate and Merge). This plugin shows a relatively short
time to do all the process until rasterization (10 to 12 seconds).
I will add this plugin in the next days after doing some cleaning of code
Best regards

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


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

2020-09-22 Thread Giuseppe Aruta
I will make those changes. Statistics are calculated in order to reuse on
raster analysis (sextante). It is also saved into a special .aux.xml
sidecar file.
At this moment there is no need to implement GeoReferencedRaster with
Statistic read as it is uìused only by Sextante.

Il giorno mar 22 set 2020 alle ore 11:59  ha scritto:

> hey Peppe,
>
> nice try, but no dice. the reason i created an explicit TiffUtilsV2 was
> to make sure it contains no reference to RasterImageIO or TiffTags
> anymore. the idea is to wrap GeoReferencedRaster functionality to reuse.
> GeoReferencedRaster includes all functionality for retrieving an
> Envelope or dimensions needed.
>
> If you are lacking functionality in GeoReferencedRaster we may add it
> accordingly.
>
> i cut some code parts below and commented them which should be replaced
> by using GeoReferencedRaster routines. ..ede
>
>
>
> On 9/22/2020 11:26, jump-pilot-svn--- via Jump-pilot-devel wrote:
> > Revision: 6507
> >http://sourceforge.net/p/jump-pilot/code/6507
> > Author:   ma15569
> > Date: 2020-09-22 09:26:19 + (Tue, 22 Sep 2020)
> > Log Message:
> > ---
> > Ported functionality from TiffUtils to TiffUtilsV2.
> > Make TiffUtils deprecated
> >
> SNIP
> >
> >
> > Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java
> > ===
> > --- core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java
>  2020-09-21 13:32:21 UTC (rev 6506)
> > +++ core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java
>  2020-09-22 09:26:19 UTC (rev 6507)
> > @@ -5,7 +5,6 @@
> SNIP
> >
> > Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
> > ===
> > --- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>  2020-09-21 13:32:21 UTC (rev 6506)
> > +++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
>  2020-09-22 09:26:19 UTC (rev 6507)
> > @@ -1,14 +1,37 @@
> >   package org.openjump.core.rasterimage;
> >
> SNIP
> >
> > @@ -66,4 +89,283 @@
> >   renderedOp = JAI.create("scale", parameterBlock);
> >   return JAI.create("scale", parameterBlock);
> > }
> > +  public static ImageAndMetadata readImage(File tiffFile, Envelope
> viewportEnvelope, Resolution requestedRes,
> > +   Overviews overviews, Stats stats) throws
> NoninvertibleTransformException, IOException, FileNotFoundException,
> > +   TiffTags.TiffReadingException, Exception {
> > +
> > + // Try to read geotiff tags
> > + TiffTags.TiffMetadata tiffMetadata =
> TiffTags.readMetadata(tiffFile);
> > + int originalImageWidth = tiffMetadata.getColsCount();
> > + int originalImageHeight = tiffMetadata.getRowsCount();
> > + Resolution cellSize = tiffMetadata.getResolution();
> > + Double noData = tiffMetadata.getNoData();
> > +
> > + // Now try with tfw
> > + if (cellSize == null) {
> > +   WorldFileHandler worldFileHandler = new
> WorldFileHandler(tiffFile.getAbsolutePath(), true);
> > +   Envelope envelope =
> worldFileHandler.readWorldFile(originalImageWidth, originalImageHeight);
> > +   cellSize = new Resolution(envelope.getWidth() /
> originalImageWidth, envelope.getHeight() / originalImageHeight);
> > + }
>
> not needed. should be retrievable from GeoReferencedRaster
>
> > + Envelope wholeImageEnvelope =
> RasterImageIO.getGeoReferencing(tiffFile.getAbsolutePath(), true,
> > + new Point(originalImageWidth, originalImageHeight));
>
> Envelope as well.
>
> > + if (requestedRes == null) {
> > +   requestedRes = cellSize;
> > + }
> > +
> > + int overviewLevel = overviews.pickOverviewLevel(requestedRes);
> > +
> > + if (stats == null) {
> > +   // Statistics on all pixels
> > +   stats = calculateStats(tiffFile, noData, tiffFile);
> > + }
> > +
> SNIP
> > +   return imageAndMetadata;
> > +
> > + }
> > +
> > +   }
> > +
> > +   private static ImageAndMetadata readImage(File tiffFile, int
> overviewIndex, int indexStart, Point originalSize,
> > +   Resolution originalCellSize, Envelope wholeImageEnvelope,
> Envelope viewportEnvelope, double noDataValue,
> > +   Stats stats) throws IOException,
> NoninvertibleTransformException {
> > +
> > + ImageInputStream imageInputStream =
> ImageIO.createImageInputStream(tiffFile);
> > + Iterator iterator =
> ImageIO.getImageReaders(imageInputStream);
>
> this seems to be a leftover. we want to enforce a specific TIFF reader,
> which seems not to be done here.
>
> why exactly are there two readImage() methods needed anyway? one should
> suffice. can you remove it?
>
> > + if (iterator != null && iterator.hasNext()) {
> > +
> > +   ImageReader imageReader = iterator.next();
> > +   

Re: [JPP-Devel] SVN: [6508] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread Giuseppe Aruta
Done

Il giorno mar 22 set 2020 alle ore 12:06  ha scritto:

> Peppe, some comments inline below ..ede
>
> On 9/22/2020 11:30, jump-pilot-svn--- via Jump-pilot-devel wrote:
> > Revision: 6508
> >http://sourceforge.net/p/jump-pilot/code/6508
> > Author:   ma15569
> > Date: 2020-09-22 09:30:06 + (Tue, 22 Sep 2020)
> > Log Message:
> > ---
> > added two method to valid and to union by attribute a FeatureCollection
> >
> > Modified Paths:
> > --
> >
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
> >
> > Modified:
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
> > ===
> > ---
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
>  2020-09-22 09:26:19 UTC (rev 6507)
> > +++
> core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
>  2020-09-22 09:30:06 UTC (rev 6508)
> > @@ -8,12 +8,23 @@
> >
> >
> SNIP
> >
> >   /**
> >* This class can check if a FeatureCollection has only one Geometry
> Type
> > @@ -22,7 +33,8 @@
> >* @author Erwan Bocher
> >* @author Olivier Bedel
> >* @version 2005-08-10
> > - *
> > + * @author Giuseppe Aruta [2020-07-22]
> > + * added two method to valid and to union by attribute a
> FeatureCollection
> >*/
> >
> >   public class FeatureCollectionUtil {
> > @@ -90,4 +102,88 @@
> >   return AttributesList;
> >
> >   }
> > + /**
> > +  * Method to make a FeatureCollection valid
> > +  * @param fc
> > +  */
>
> can you add to the javadoc exactly what is the method doing to make it
> valid? why wasn't it valid before?
>
> > + public static void
> validFeatureCollection(FeatureCollection fc) {
> > + MakeValidOp makeValidOp = new MakeValidOp();
> > +  makeValidOp.setPreserveGeomDim(true);
> > +  makeValidOp.setPreserveDuplicateCoord(false);
> > +  for (Feature feature  : fc.getFeatures()) {
> > +   Geometry validGeom =
> makeValidOp.makeValid(feature.getGeometry());
> > +   feature.setGeometry(validGeom);
> > + }
> > +   // return fc;
> > +}
> > +
> > + /**
> > +  * Mathod to merge geometries of a FeaureCollection
> according
>
> probably "Method to merge geometries of a FeatureCollection according"
>
> > +  * to an attribute
> > +  * @param featureCollection
> > +  * @param value
>
> what is the value. looks like the attribute name to me. please javadoc it
>
> > +  * @throws Exception
> > +  */
> > +  public static void
> unionByAttributeValue(FeatureCollection featureCollection, String value)
> throws Exception {
> > +   FeatureSchema schema =
> featureCollection.getFeatureSchema();
> > +   if (featureCollection.getFeatures().size() > 1 &&
> > +
>  featureCollection.getFeatures().get(0).getGeometry() != null) {
> > +
>  featureCollection.getFeatures().get(0).getGeometry().getFactory();
> > + }
> > + else {
> > + Logger.error(
> > +
>  I18N.get("ui.plugin.analysis.DissolvePlugIn.needs-two-features-or-more"));
> > +   // return null;
> > + }
> > + FeatureSchema newSchema;
> > + newSchema = schema;
> > + Map map = new
> HashMap();
> > + for (Feature feature  :
> featureCollection.getFeatures()) {
> > +  Object key = feature.getAttribute(value);
> > +  if (!map.containsKey(key)) {
> > +  FeatureCollection fd = new
> FeatureDataset(featureCollection.getFeatureSchema());
> > +  fd.add(feature);
> > +  map.put(key, fd);
> > +  }  else {
> > +  map.get(key).add(feature);
> > +  }
> > +  }
> > +
>  featureCollection.removeAll(featureCollection.getFeatures());
> > + for (Iterator i =
> map.keySet().iterator() ; i.hasNext() ; ) {
> > + Object key = i.next();
> > + FeatureCollection fca = map.get(key);
> > + if (fca.size() > 0) {
> > +   Feature feature = union(fca);
> > +   feature.setAttribute(value, key);
> > +   Feature newFeature = new
> BasicFeature(newSchema);
> > + // Copy feature attributes in
> newFeature
> > +   for (int j = 0, max =
> newSchema.getAttributeCount() ; 

[JPP-Devel] SVN: [6512] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6512
  http://sourceforge.net/p/jump-pilot/code/6512
Author:   ma15569
Date: 2020-09-22 10:25:35 + (Tue, 22 Sep 2020)
Log Message:
---
Javadoc

Modified Paths:
--
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java

Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
===
--- core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 10:04:12 UTC (rev 6511)
+++ core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 10:25:35 UTC (rev 6512)
@@ -103,8 +103,18 @@

 }
/**
-* Method to make a FeatureCollection valid   
-* @param fc
+* Method to make valid all the geometries of a FeatureCollection
+* using the class MakeValidOp.
+* A geometry is not valid if it is not simple:
+* This condition occurs when any of the following conditions are true:
+* Incorrect ring orientation (polygon), self-intersection rings 
(polygon)
+* self-intersection path (polyline), unclosed ring (polygon)
+* (see also 
https://desktop.arcgis.com/en/arcmap/latest/extensions/data-reviewer/finding-invalid-geometry.htm
+* for the complete list).
+* This method should be applied before merge feature
+* [see method unionByAttributeValue(FeatureCollection 
featureCollection, String attrbuteName)]
+* as not simple geometries will be not processed
+* @param FeatureCollection fc
 */
public static void validFeatureCollection(FeatureCollection fc) {
MakeValidOp makeValidOp = new MakeValidOp();
@@ -119,12 +129,12 @@

/**
 * Mathod to merge geometries of a FeaureCollection according
-* to an attribute
-* @param featureCollection
-* @param value
+* to the values of an attribute name
+* @param FeatureCollection fc
+* @param String attrbuteName
 * @throws Exception
 */
-public static void unionByAttributeValue(FeatureCollection 
featureCollection, String value) throws Exception {
+public static void unionByAttributeValue(FeatureCollection 
featureCollection, String attrbuteName) throws Exception {
  FeatureSchema schema = featureCollection.getFeatureSchema();
  if (featureCollection.getFeatures().size() > 1 &&

featureCollection.getFeatures().get(0).getGeometry() != null) {
@@ -139,7 +149,7 @@
newSchema = schema;
Map map = new HashMap();
for (Feature feature  : featureCollection.getFeatures()) {
-Object key = feature.getAttribute(value);
+Object key = feature.getAttribute(attrbuteName);
 if (!map.containsKey(key)) {
 FeatureCollection fd = new 
FeatureDataset(featureCollection.getFeatureSchema());
 fd.add(feature);
@@ -154,7 +164,7 @@
FeatureCollection fca = map.get(key);
if (fca.size() > 0) {
  Feature feature = union(fca);
- feature.setAttribute(value, key);
+ feature.setAttribute(attrbuteName, key);
  Feature newFeature = new BasicFeature(newSchema);
// Copy feature attributes in newFeature
  for (int j = 0, max = newSchema.getAttributeCount() ; 
j < max ; j++) {



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


Re: [JPP-Devel] SVN: [6508] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread edgar . soldin

Peppe, some comments inline below ..ede

On 9/22/2020 11:30, jump-pilot-svn--- via Jump-pilot-devel wrote:

Revision: 6508
   http://sourceforge.net/p/jump-pilot/code/6508
Author:   ma15569
Date: 2020-09-22 09:30:06 + (Tue, 22 Sep 2020)
Log Message:
---
added two method to valid and to union by attribute a FeatureCollection

Modified Paths:
--
 core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java

Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
===
--- core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 09:26:19 UTC (rev 6507)
+++ core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 09:30:06 UTC (rev 6508)
@@ -8,12 +8,23 @@
  
  

SNIP
  
  /**

   * This class can check if a FeatureCollection has only one Geometry Type
@@ -22,7 +33,8 @@
   * @author Erwan Bocher
   * @author Olivier Bedel
   * @version 2005-08-10
- *
+ * @author Giuseppe Aruta [2020-07-22]
+ * added two method to valid and to union by attribute a FeatureCollection
   */
  
  public class FeatureCollectionUtil {

@@ -90,4 +102,88 @@
return AttributesList;

  }
+   /**
+* Method to make a FeatureCollection valid
+* @param fc
+*/


can you add to the javadoc exactly what is the method doing to make it valid? 
why wasn't it valid before?


+   public static void validFeatureCollection(FeatureCollection fc) {
+   MakeValidOp makeValidOp = new MakeValidOp();
+makeValidOp.setPreserveGeomDim(true);
+makeValidOp.setPreserveDuplicateCoord(false);
+for (Feature feature  : fc.getFeatures()) {
+ Geometry validGeom = 
makeValidOp.makeValid(feature.getGeometry());
+ feature.setGeometry(validGeom);
+   }
+ // return fc;
+  }
+   
+   /**
+* Mathod to merge geometries of a FeaureCollection according


probably "Method to merge geometries of a FeatureCollection according"


+* to an attribute
+* @param featureCollection
+* @param value


what is the value. looks like the attribute name to me. please javadoc it


+* @throws Exception
+*/
+public static void unionByAttributeValue(FeatureCollection 
featureCollection, String value) throws Exception {
+ FeatureSchema schema = featureCollection.getFeatureSchema();
+ if (featureCollection.getFeatures().size() > 1 &&
+   
featureCollection.getFeatures().get(0).getGeometry() != null) {
+   
featureCollection.getFeatures().get(0).getGeometry().getFactory();
+   }
+   else {
+   Logger.error(
+   
I18N.get("ui.plugin.analysis.DissolvePlugIn.needs-two-features-or-more"));
+ // return null;
+   }
+   FeatureSchema newSchema;
+   newSchema = schema;
+   Map map = new HashMap();
+   for (Feature feature  : featureCollection.getFeatures()) {
+Object key = feature.getAttribute(value);
+if (!map.containsKey(key)) {
+FeatureCollection fd = new 
FeatureDataset(featureCollection.getFeatureSchema());
+fd.add(feature);
+map.put(key, fd);
+}  else {
+map.get(key).add(feature);
+}
+}
+   featureCollection.removeAll(featureCollection.getFeatures());
+   for (Iterator i = map.keySet().iterator() ; 
i.hasNext() ; ) {
+   Object key = i.next();
+   FeatureCollection fca = map.get(key);
+   if (fca.size() > 0) {
+ Feature feature = union(fca);
+ feature.setAttribute(value, key);
+ Feature newFeature = new BasicFeature(newSchema);
+   // Copy feature attributes in newFeature
+ for (int j = 0, max = newSchema.getAttributeCount() ; j 
< max ; j++) {
+   newFeature.setAttribute(j, 
feature.getAttribute(newSchema.getAttributeName(j)));
+}
+ featureCollection.add(newFeature);
+   }
+   }
+  // return featureCollection;
+}
+
+   
+private static Feature union(FeatureCollection fc) {
+GeometryFactory factory = new GeometryFactory();
+Collection geometries  = new ArrayList();
+for (Feature f :  fc.getFeatures()) {
+Geometry g = f.getGeometry();
+ 

[JPP-Devel] SVN: [6511] core/trunk/src/org/openjump/core/ui/plugin/tools/generate/ RasterizePlugIn.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6511
  http://sourceforge.net/p/jump-pilot/code/6511
Author:   ma15569
Date: 2020-09-22 10:04:12 + (Tue, 22 Sep 2020)
Log Message:
---
Added Rasterize vector plugin

Added Paths:
---

core/trunk/src/org/openjump/core/ui/plugin/tools/generate/RasterizePlugIn.java

Added: 
core/trunk/src/org/openjump/core/ui/plugin/tools/generate/RasterizePlugIn.java
===
--- 
core/trunk/src/org/openjump/core/ui/plugin/tools/generate/RasterizePlugIn.java  
(rev 0)
+++ 
core/trunk/src/org/openjump/core/ui/plugin/tools/generate/RasterizePlugIn.java  
2020-09-22 10:04:12 UTC (rev 6511)
@@ -0,0 +1,314 @@
+
+
+/** 
+ * created:21. Sept.2020
+ * 
+ * @author Giuseppe Aruta
+ * @TODO clip the vectors to the envelope before
+ * validating them. THis can make the process faster
+ * 
+ * 
+ * @description: A tool to rasterize a vector layer.
+ * - make valid the layer
+ * - union by the value selected for rasterizing
+ * - rasterize the vectors limiting into an envelope
+ * 
+ */
+
+package org.openjump.core.ui.plugin.tools.generate;
+
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.openjump.core.rasterimage.RasterImageLayer;
+import org.openjump.core.rasterimage.algorithms.GenericRasterAlgorithm;
+import org.openjump.core.rasterimage.algorithms.RasterizeAlgorithm;
+import org.openjump.core.ui.io.file.FileNameExtensionFilter;
+import org.openjump.sigle.utilities.geom.FeatureCollectionUtil;
+import org.saig.core.gui.swing.sldeditor.util.FormUtils;
+
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.feature.Feature;
+import com.vividsolutions.jump.feature.FeatureCollection;
+import com.vividsolutions.jump.feature.FeatureDataset;
+import com.vividsolutions.jump.feature.FeatureSchema;
+import com.vividsolutions.jump.task.TaskMonitor;
+import com.vividsolutions.jump.util.FileUtil;
+import com.vividsolutions.jump.workbench.JUMPWorkbench;
+import com.vividsolutions.jump.workbench.WorkbenchContext;
+import com.vividsolutions.jump.workbench.model.Category;
+import com.vividsolutions.jump.workbench.model.Layer;
+import com.vividsolutions.jump.workbench.model.Layerable;
+import com.vividsolutions.jump.workbench.model.StandardCategoryNames;
+import com.vividsolutions.jump.workbench.model.WMSLayer;
+import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
+import com.vividsolutions.jump.workbench.plugin.EnableCheck;
+import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
+import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.plugin.ThreadedPlugIn;
+import com.vividsolutions.jump.workbench.ui.AttributeTypeFilter;
+import com.vividsolutions.jump.workbench.ui.GUIUtil;
+import com.vividsolutions.jump.workbench.ui.GenericNames;
+import com.vividsolutions.jump.workbench.ui.LayerNameRenderer;
+import com.vividsolutions.jump.workbench.ui.MenuNames;
+import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
+import com.vividsolutions.jump.workbench.ui.images.IconLoader;
+
+import de.latlon.deejump.wfs.jump.WFSLayer;
+import it.betastudio.adbtoolbox.libs.FileOperations;
+
+ 
+ 
+public class RasterizePlugIn extends AbstractPlugIn
+implements ThreadedPlugIn {
+
+   private Layer layer;
+   private JTextField cellYextFiels;
+   private JComboBox layerComboBox = new JComboBox();
+  
+   private JLabel cutLayerLabel;
+   private DefaultComboBoxModel sourceLayerComboBoxModel = new 
DefaultComboBoxModel();
+   private String selAttribute = null;
+   private String ATTRIBUTE = GenericNames.SELECT_ATTRIBUTE;
+   private String path;
+   double cellValue;
+   private final ImageIcon icon16 = IconLoader
+   .icon("fugue/folder-horizontal-open_16.png");
+   JTextField jTextField_RasterOut = new JTextField();
+   private final String OUTPUT_FILE = I18N
+   .get("driver.DriverManager.file-to-save");
+   private final String CHECK = 
I18N.get("ui.GenericNames.chech-field");
+   private final static String LAYER = 
I18N.get("ui.plugin.analysis.DissolvePlugIn.source-layer");
+   private final static String TARGET_LAYER = 

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

2020-09-22 Thread edgar . soldin

hey Peppe,

nice try, but no dice. the reason i created an explicit TiffUtilsV2 was
to make sure it contains no reference to RasterImageIO or TiffTags
anymore. the idea is to wrap GeoReferencedRaster functionality to reuse.
GeoReferencedRaster includes all functionality for retrieving an
Envelope or dimensions needed.

If you are lacking functionality in GeoReferencedRaster we may add it
accordingly.

i cut some code parts below and commented them which should be replaced
by using GeoReferencedRaster routines. ..ede



On 9/22/2020 11:26, jump-pilot-svn--- via Jump-pilot-devel wrote:

Revision: 6507
   http://sourceforge.net/p/jump-pilot/code/6507
Author:   ma15569
Date: 2020-09-22 09:26:19 + (Tue, 22 Sep 2020)
Log Message:
---
Ported functionality from TiffUtils to TiffUtilsV2.
Make TiffUtils deprecated


SNIP
  


Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java 2020-09-21 
13:32:21 UTC (rev 6506)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java 2020-09-22 
09:26:19 UTC (rev 6507)
@@ -5,7 +5,6 @@

SNIP


Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-21 13:32:21 UTC (rev 6506)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 09:26:19 UTC (rev 6507)
@@ -1,14 +1,37 @@
  package org.openjump.core.rasterimage;
  

SNIP
  
@@ -66,4 +89,283 @@

  renderedOp = JAI.create("scale", parameterBlock);
  return JAI.create("scale", parameterBlock);
}
+  public static ImageAndMetadata readImage(File tiffFile, Envelope 
viewportEnvelope, Resolution requestedRes,
+ Overviews overviews, Stats stats) throws 
NoninvertibleTransformException, IOException, FileNotFoundException,
+ TiffTags.TiffReadingException, Exception {
+
+   // Try to read geotiff tags
+   TiffTags.TiffMetadata tiffMetadata = 
TiffTags.readMetadata(tiffFile);
+   int originalImageWidth = tiffMetadata.getColsCount();
+   int originalImageHeight = tiffMetadata.getRowsCount();
+   Resolution cellSize = tiffMetadata.getResolution();
+   Double noData = tiffMetadata.getNoData();
+
+   // Now try with tfw
+   if (cellSize == null) {
+ WorldFileHandler worldFileHandler = new 
WorldFileHandler(tiffFile.getAbsolutePath(), true);
+ Envelope envelope = 
worldFileHandler.readWorldFile(originalImageWidth, originalImageHeight);
+ cellSize = new Resolution(envelope.getWidth() / 
originalImageWidth, envelope.getHeight() / originalImageHeight);
+   }


not needed. should be retrievable from GeoReferencedRaster


+   Envelope wholeImageEnvelope = 
RasterImageIO.getGeoReferencing(tiffFile.getAbsolutePath(), true,
+   new Point(originalImageWidth, originalImageHeight));


Envelope as well.


+   if (requestedRes == null) {
+ requestedRes = cellSize;
+   }
+
+   int overviewLevel = overviews.pickOverviewLevel(requestedRes);
+
+   if (stats == null) {
+ // Statistics on all pixels
+ stats = calculateStats(tiffFile, noData, tiffFile);
+   }
+

SNIP

+ return imageAndMetadata;
+
+   }
+
+ }
+
+ private static ImageAndMetadata readImage(File tiffFile, int 
overviewIndex, int indexStart, Point originalSize,
+ Resolution originalCellSize, Envelope wholeImageEnvelope, 
Envelope viewportEnvelope, double noDataValue,
+ Stats stats) throws IOException, NoninvertibleTransformException {
+
+   ImageInputStream imageInputStream = 
ImageIO.createImageInputStream(tiffFile);
+   Iterator iterator = 
ImageIO.getImageReaders(imageInputStream);


this seems to be a leftover. we want to enforce a specific TIFF reader, which 
seems not to be done here.

why exactly are there two readImage() methods needed anyway? one should 
suffice. can you remove it?


+   if (iterator != null && iterator.hasNext()) {
+
+ ImageReader imageReader = iterator.next();
+ imageReader.setInput(imageInputStream);
+ for (int i = 0; i < imageReader.getNumImages(true); i++) {
+   if (i + indexStart == overviewIndex) {
+
+ Resolution subsetResolution = new 
Resolution(wholeImageEnvelope.getWidth() / imageReader.getWidth(i),
+ wholeImageEnvelope.getHeight() / 
imageReader.getHeight(i));
+
+ Rectangle imageSubset = 
RasterImageIO.getDrawingRectangle(imageReader.getWidth(i), 
imageReader.getHeight(i),
+ wholeImageEnvelope, viewportEnvelope, subsetResolution);
+
+ BufferedImage 

[JPP-Devel] SVN: [6510] core/trunk/src/com/vividsolutions/jump/workbench/ui/images/ rasterize.png

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6510
  http://sourceforge.net/p/jump-pilot/code/6510
Author:   ma15569
Date: 2020-09-22 09:54:15 + (Tue, 22 Sep 2020)
Log Message:
---
Add icon for rasterize plugin

Added Paths:
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/images/rasterize.png

Added: core/trunk/src/com/vividsolutions/jump/workbench/ui/images/rasterize.png
===
(Binary files differ)

Index: core/trunk/src/com/vividsolutions/jump/workbench/ui/images/rasterize.png
===
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/images/rasterize.png
2020-09-22 09:39:49 UTC (rev 6509)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/images/rasterize.png
2020-09-22 09:54:15 UTC (rev 6510)

Property changes on: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/images/rasterize.png
___
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property


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


[JPP-Devel] SVN: [6509] core/trunk/src/org/openjump/core/rasterimage/algorithms/ RasterizeAlgorithm.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6509
  http://sourceforge.net/p/jump-pilot/code/6509
Author:   ma15569
Date: 2020-09-22 09:39:49 + (Tue, 22 Sep 2020)
Log Message:
---
Added two methods (from Sextante and from AdbToolbox) to rasterize a vector 
layer. Those methods are modified in order to speed up thye process and to 
retrive a valid output

Added Paths:
---

core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java

Added: 
core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java
===
--- 
core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java 
(rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java 
2020-09-22 09:39:49 UTC (rev 6509)
@@ -0,0 +1,532 @@
+package org.openjump.core.rasterimage.algorithms;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.WritableRaster;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.openjump.core.rasterimage.RasterImageIO;
+import org.openjump.core.rasterimage.sextante.rasterWrappers.GridCell;
+import org.openjump.core.rasterimage.sextante.rasterWrappers.GridExtent;
+import org.openjump.core.rasterimage.sextante.rasterWrappers.GridRasterWrapper;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryCollection;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.geom.Polygon;
+import com.vividsolutions.jump.feature.Feature;
+import com.vividsolutions.jump.feature.FeatureCollection;
+import com.vividsolutions.jump.feature.FeatureDataset;
+import com.vividsolutions.jump.feature.FeatureSchema;
+
+ 
+/**
+ * 
+ * @author Giuseppe Aruta
+ * a class to port two methods to rasterize a FeatureCollection
+ * - from Sextante (https://joinup.ec.europa.eu/solution/sextante/about)
+ * - from AdbToolbox (http://www.pcn.minambiente.it/mattm/adb-toolbox/)
+ */
+ 
+
+public class RasterizeAlgorithm {
+
+   private static Double NO_DATA;
+   private static Double cellSize;
+   private static double dValue;
+   private static int m_iNX;
+   private static int m_iNY;
+
+   //private static OpenJUMPSextanteRasterLayer sRasterLayer;
+   private static GridExtent m_Extent;
+ 
+
+  static WritableRaster raster;
+   
+  
+   /**
+   * Method to rasterize a FeatureCollection using AdBToolbox framework
+   * @TODO check why the output shows non exact values
+   * @param file
+   * @param Envelope limitEnvelope
+   * @param Layer m_Layer
+   * @param String attributeName
+   * @param double CellSize
+   * @param double NoData
+   * @throws IOException
+
+   */
+  
+  public static void Rasterize_AdbToolbox(File file, Envelope 
limitEnvelope, FeatureCollection fCollection, String attributeName, double 
CellSize, double NoData) throws IOException  {
+NO_DATA=NoData;
+cellSize=CellSize;
+m_Extent=  new GridExtent();
+  m_Extent.setCellSize(CellSize, CellSize);
+  m_Extent.setXRange(limitEnvelope.getMinX(), 
limitEnvelope.getMaxX());
+  m_Extent.setYRange(limitEnvelope.getMinY(), 
limitEnvelope.getMaxY()); 
+
+  m_iNX = m_Extent.getNX();
+  m_iNY = m_Extent.getNY();
+ double[][] valori= new double[m_iNX][m_iNY];
+ 
+ for (int x = 0; x < m_iNX; x++){
+   for (int y = 0; y < m_iNY; y++){
+   valori[x][y]=NoData;
+
+   }
+   }
+ 
+   raster = GridRasterWrapper.matrixToRaster(valori);
+   BufferedImage bimage = new BufferedImage(m_iNX, m_iNY, 
BufferedImage.TYPE_INT_ARGB);
+   bimage.setAccelerationPriority(1.0f);
+   Graphics2D graphics = bimage.createGraphics();
+
+   Coordinate[] coord;
+   int[] coordGridX;
+   int[] coordGridY;
+
+   Color color = new Color(100);
+   graphics.setPaint(color);
+   graphics.setPaintMode();
+
+
+
+
+ final Coordinate[] coords = new Coordinate[5];
+ coords[0] = new Coordinate(limitEnvelope.getMinX(), 

[JPP-Devel] SVN: [6508] core/trunk/src/org/openjump/sigle/utilities/geom/ FeatureCollectionUtil.java

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6508
  http://sourceforge.net/p/jump-pilot/code/6508
Author:   ma15569
Date: 2020-09-22 09:30:06 + (Tue, 22 Sep 2020)
Log Message:
---
added two method to valid and to union by attribute a FeatureCollection

Modified Paths:
--
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java

Modified: 
core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java
===
--- core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 09:26:19 UTC (rev 6507)
+++ core/trunk/src/org/openjump/sigle/utilities/geom/FeatureCollectionUtil.java 
2020-09-22 09:30:06 UTC (rev 6508)
@@ -8,12 +8,23 @@
 
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 
+import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.GeometryCollection;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.operation.union.UnaryUnionOp;
+import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.feature.BasicFeature;
 import com.vividsolutions.jump.feature.Feature;
 import com.vividsolutions.jump.feature.FeatureCollection;
+import com.vividsolutions.jump.feature.FeatureDataset;
 import com.vividsolutions.jump.feature.FeatureSchema;
+import com.vividsolutions.jump.geom.MakeValidOp;
+import com.vividsolutions.jump.workbench.Logger;
 
 /**
  * This class can check if a FeatureCollection has only one Geometry Type
@@ -22,7 +33,8 @@
  * @author Erwan Bocher 
  * @author Olivier Bedel
  * @version 2005-08-10
- *
+ * @author Giuseppe Aruta [2020-07-22]
+ * added two method to valid and to union by attribute a FeatureCollection
  */
 
 public class FeatureCollectionUtil {
@@ -90,4 +102,88 @@
return AttributesList;

 }
+   /**
+* Method to make a FeatureCollection valid   
+* @param fc
+*/
+   public static void validFeatureCollection(FeatureCollection fc) {
+   MakeValidOp makeValidOp = new MakeValidOp();
+makeValidOp.setPreserveGeomDim(true);
+makeValidOp.setPreserveDuplicateCoord(false);
+for (Feature feature  : fc.getFeatures()) {
+ Geometry validGeom = 
makeValidOp.makeValid(feature.getGeometry());
+ feature.setGeometry(validGeom);
+   }
+ // return fc; 
+  }
+   
+   /**
+* Mathod to merge geometries of a FeaureCollection according
+* to an attribute
+* @param featureCollection
+* @param value
+* @throws Exception
+*/
+public static void unionByAttributeValue(FeatureCollection 
featureCollection, String value) throws Exception {
+ FeatureSchema schema = featureCollection.getFeatureSchema();
+ if (featureCollection.getFeatures().size() > 1 &&
+   
featureCollection.getFeatures().get(0).getGeometry() != null) {
+   
featureCollection.getFeatures().get(0).getGeometry().getFactory();
+   }
+   else {
+   Logger.error(
+   
I18N.get("ui.plugin.analysis.DissolvePlugIn.needs-two-features-or-more"));
+ // return null;
+   }
+   FeatureSchema newSchema;
+   newSchema = schema;
+   Map map = new HashMap();
+   for (Feature feature  : featureCollection.getFeatures()) {
+Object key = feature.getAttribute(value);
+if (!map.containsKey(key)) {
+FeatureCollection fd = new 
FeatureDataset(featureCollection.getFeatureSchema());
+fd.add(feature);
+map.put(key, fd);
+}  else {
+map.get(key).add(feature);
+}
+}
+   featureCollection.removeAll(featureCollection.getFeatures());
+   for (Iterator i = map.keySet().iterator() ; 
i.hasNext() ; ) {
+   Object key = i.next();
+   FeatureCollection fca = map.get(key);
+   if (fca.size() > 0) {
+ Feature feature = union(fca);
+ feature.setAttribute(value, key);
+ Feature newFeature = new BasicFeature(newSchema);
+   // Copy feature attributes in newFeature
+ for (int j = 0, max = newSchema.getAttributeCount() ; 
j < max ; j++) {
+   newFeature.setAttribute(j, 
feature.getAttribute(newSchema.getAttributeName(j)));
+}
+ featureCollection.add(newFeature);
+   }
+  

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

2020-09-22 Thread jump-pilot-svn--- via Jump-pilot-devel
Revision: 6507
  http://sourceforge.net/p/jump-pilot/code/6507
Author:   ma15569
Date: 2020-09-22 09:26:19 + (Tue, 22 Sep 2020)
Log Message:
---
Ported functionality from TiffUtils to TiffUtilsV2.
Make TiffUtils deprecated

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

Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java
===
--- core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java 
2020-09-21 13:32:21 UTC (rev 6506)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIO.java 
2020-09-22 09:26:19 UTC (rev 6507)
@@ -26,7 +26,6 @@
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
-import org.openjump.core.rasterimage.TiffTags.TiffMetadata;
 
 import com.sun.media.jai.codec.FileSeekableStream;
 import com.sun.media.jai.codec.TIFFDirectory;
@@ -38,8 +37,6 @@
 import com.vividsolutions.jts.geom.Envelope;
 import com.vividsolutions.jump.I18N;
 import com.vividsolutions.jump.workbench.WorkbenchContext;
-import com.vividsolutions.jump.workbench.imagery.ReferencedImageException;
-import com.vividsolutions.jump.workbench.imagery.geoimg.GeoReferencedRaster;
 import com.vividsolutions.jump.workbench.ui.Viewport;
 
 /**
@@ -146,7 +143,7 @@
   Envelope imageEnvelope = TiffUtilsV2.getEnvelope(tiffFile);
   Overviews overviews = OverviewsUtils.getOverviews(new 
File(fileNameOrURL), imageEnvelope);
 
-  return TiffUtils.readImage(tiffFile, viewPortEnvelope, requestedRes, 
overviews, stats);
+  return TiffUtilsV2.readImage(tiffFile, viewPortEnvelope, requestedRes, 
overviews, stats);
 
 } else if (fileNameOrURL.toLowerCase().endsWith(".flt")) {
 

Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java 2020-09-21 
13:32:21 UTC (rev 6506)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java 2020-09-22 
09:26:19 UTC (rev 6507)
@@ -5,7 +5,6 @@
 import java.awt.geom.NoninvertibleTransformException;
 import java.awt.image.BufferedImage;
 import java.awt.image.Raster;
-import java.awt.image.renderable.ParameterBlock;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -16,9 +15,7 @@
 import javax.imageio.ImageReadParam;
 import javax.imageio.ImageReader;
 import javax.imageio.stream.ImageInputStream;
-import javax.media.jai.JAI;
 import javax.media.jai.RenderedOp;
-import javax.media.jai.util.ImagingListener;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
@@ -36,7 +33,10 @@
 /**
  *
  * @author AdL
+ * @deprecated moved all methods to newer
+ * org.openjump.core.rasterimage.TiffUtilsV2 class
  */
+@Deprecated
 public class TiffUtils {
 
   public static ImageAndMetadata readImage(File tiffFile, Envelope 
viewportEnvelope, Resolution requestedRes,

Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-21 13:32:21 UTC (rev 6506)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java   
2020-09-22 09:26:19 UTC (rev 6507)
@@ -1,14 +1,37 @@
 package org.openjump.core.rasterimage;
 
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
 import java.awt.image.renderable.ParameterBlock;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReadParam;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
 import javax.media.jai.JAI;
 import javax.media.jai.RenderedOp;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
 
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.formats.tiff.TiffField;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.TiffImageParser;
+import org.xml.sax.SAXException;
+
+import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jump.workbench.Logger;
 import