[JPP-Devel] Bug on saving layer to SHP

2015-06-16 Thread Giuseppe Aruta
Hi,
this is the message I had when I tired to save a vector layer to Shapefile:

java.lang.StringIndexOutOfBoundsException: String index out of range: 8
at java.lang.String.substring(String.java:1907)
at
com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
at
com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
at
com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
at
com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
at
com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
at java.lang.Thread.run(Thread.java:744)

Saving to JML works fine
Peppe
--
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] Bug on saving layer to SHP

2015-06-16 Thread Giuseppe Aruta
The version I tested is OpenJUMP-20150613-r4493-PLUS

2015-06-16 9:58 GMT+02:00 Giuseppe Aruta :

> Hi,
> this is the message I had when I tired to save a vector layer to Shapefile:
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
> at java.lang.String.substring(String.java:1907)
> at
> com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
> at
> com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
> at
> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
> at
> com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
> at
> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
> at java.lang.Thread.run(Thread.java:744)
>
> Saving to JML works fine
> Peppe
>
--
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] Bug on saving layer to SHP

2015-06-16 Thread Giuseppe Aruta
This is the file saved as JML that cannot be saved to SHP.
I belive is something in the file, not in OJ

2015-06-16 9:59 GMT+02:00 Giuseppe Aruta :

> The version I tested is OpenJUMP-20150613-r4493-PLUS
>
> 2015-06-16 9:58 GMT+02:00 Giuseppe Aruta :
>
>> Hi,
>> this is the message I had when I tired to save a vector layer to
>> Shapefile:
>>
>> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>> at java.lang.String.substring(String.java:1907)
>> at
>> com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
>> at
>> com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
>> at
>> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
>> at
>> com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
>> at
>> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
>> at java.lang.Thread.run(Thread.java:744)
>>
>> Saving to JML works fine
>> Peppe
>>
>
>


Misure.jml
Description: Binary data
--
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] Bug on saving layer to SHP

2015-06-16 Thread Johannes Kröger
Hey Giuseppe,

yay, little morning programming practise for me. :)

If I read it correctly it fails with any column name shorter than 8
characters, weird how this was never catched before (or I am just on
the wrong path).

My line numbers are slightly off but I assume the following block is
where it errors for you:
 if (count<10) columnName = columnName.substring(0,8) + "_" + count;
 else columnName = columnName.substring(0,8) + count;

The hardcoded 8 is a problem here. A few lines above columnName is
defined as:
 columnName = columnName.substring(0,Math.min(columnName.length(), 10));
Names will be truncated to a maximum of 10 characters here or stay as
they are if they were <= 10 already.

Basically what seems to happen here is this:
 // A String with less than 8 characters
 String test = "1234567";
 // Truncate to the shorter of its length or 10, here 7 so no truncation
 test = test.substring(0,Math.min(test.length(), 10));
 // Extract the substring up to index 8 (including)
 test = test.substring(0,8);
 // test's highest index is 7, so it's OOB

The substring operations within the if/else need to take care of
strings shorter than 8 characters and truncate accordingly.

Cheers, Hannes

PS: SHP begone!

PPS: It will also fail rather badly if there are more than 99
identically truncated names ;)

PPPS: Wouldn't it result in ambiguity if the truncation from 10 to 8
characters leads to the same string of previously different names?
abcdefghij and abcdefghik would both result in abcdefgh as "truncated +
count" column name.

On Tue, 16 Jun 2015 07:58:53 +
jump-pilot-devel-requ...@lists.sourceforge.net wrote:

> Date: Tue, 16 Jun 2015 09:58:47 +0200
> From: Giuseppe Aruta 
> Subject: [JPP-Devel] Bug on saving layer to SHP
> To: OpenJump develop and use 
> Message-ID:
>   
> Content-Type: text/plain; charset="utf-8"
> 
> Hi,
> this is the message I had when I tired to save a vector layer to
> Shapefile:
> 
> java.lang.StringIndexOutOfBoundsException: String index out of range:
> 8 at java.lang.String.substring(String.java:1907)
> at
> com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
> at
> com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
> at
> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
> at
> com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
> at
> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
> at java.lang.Thread.run(Thread.java:744)
> 
> Saving to JML works fine
> Peppe

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


Re: [JPP-Devel] Bug on saving layer to SHP

2015-06-16 Thread Rahkonen Jukka (MML)
Hi,

There is two times an attribute named "LENGTH" in the schema of "Misure".

Attribute names in shapefile can only be 10 chararters long and OJ tries to 
take care that if a longer attribute must be truncated it will still get an 
unique name.
So, cut attribute name to 8 characters, check if there are duplicates, add a 
numeric ending to the body for making them unique.

What is exceptional is that Peppe has created a file that has duplicated and 
less than 10 characters long attribute names natively. OpenJUMP does not take 
this situation into account.

But I wonder how this layer is created? It is not possible to create duplicate 
attribute names from the GUI.

-Jukka Rahkonen-




Johannes Kröger wrote:

> Hey Giuseppe,

> yay, little morning programming practise for me. :)

> If I read it correctly it fails with any column name shorter than 8 
> characters, weird how this was never catched before (or I am just on the 
> wrong path).

> My line numbers are slightly off but I assume the following block is where it 
> errors for you:
 if (count<10) columnName = columnName.substring(0,8) + "_" + count;  else 
columnName = columnName.substring(0,8) + count;

> The hardcoded 8 is a problem here. A few lines above columnName is defined as:
 columnName = columnName.substring(0,Math.min(columnName.length(), 10)); Names 
will be truncated to a maximum of 10 characters here or stay as they are if 
they were <= 10 already.

> Basically what seems to happen here is this:
 // A String with less than 8 characters  String test = "1234567";  // Truncate 
to the shorter of its length or 10, here 7 so no truncation  test = 
test.substring(0,Math.min(test.length(), 10));  // Extract the substring up to 
index 8 (including)  test = test.substring(0,8);  // test's highest index is 7, 
so it's OOB

> The substring operations within the if/else need to take care of strings 
> shorter than 8 characters and truncate accordingly.

> Cheers, Hannes

> PS: SHP begone!

> PPS: It will also fail rather badly if there are more than 99 identically 
> truncated names ;)

> PPPS: Wouldn't it result in ambiguity if the truncation from 10 to 8 
> characters leads to the same string of previously different names?
abcdefghij and abcdefghik would both result in abcdefgh as "truncated + count" 
column name.

On Tue, 16 Jun 2015 07:58:53 +
jump-pilot-devel-requ...@lists.sourceforge.net wrote:

> Date: Tue, 16 Jun 2015 09:58:47 +0200
> From: Giuseppe Aruta 
> Subject: [JPP-Devel] Bug on saving layer to SHP
> To: OpenJump develop and use 
> Message-ID:
>   
> Content-Type: text/plain; charset="utf-8"
> 
> Hi,
> this is the message I had when I tired to save a vector layer to
> Shapefile:
> 
> java.lang.StringIndexOutOfBoundsException: String index out of range:
> 8 at java.lang.String.substring(String.java:1907)
> at
> com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
> at
> com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
> at
> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
> at
> com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
> at
> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
> at java.lang.Thread.run(Thread.java:744)
> 
> Saving to JML works fine
> Peppe

--
___
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] Bug on saving layer to SHP

2015-06-16 Thread Giuseppe Aruta
Thanks Johannes and Jukka,
that was the two attribute named "LENGTH" that created the problem. It was
an old file created with an experimental measure plugin (made a long ago)
that I wanted to resume and to try to use a part of the code. Cancelling on
the code the one of LENGTH attribute let it work.
Bug solved
Thank again
Peppe

2015-06-16 12:08 GMT+02:00 Rahkonen Jukka (MML) <
jukka.rahko...@maanmittauslaitos.fi>:

> Hi,
>
> There is two times an attribute named "LENGTH" in the schema of "Misure".
>
> Attribute names in shapefile can only be 10 chararters long and OJ tries
> to take care that if a longer attribute must be truncated it will still get
> an unique name.
> So, cut attribute name to 8 characters, check if there are duplicates, add
> a numeric ending to the body for making them unique.
>
> What is exceptional is that Peppe has created a file that has duplicated
> and less than 10 characters long attribute names natively. OpenJUMP does
> not take this situation into account.
>
> But I wonder how this layer is created? It is not possible to create
> duplicate attribute names from the GUI.
>
> -Jukka Rahkonen-
>
>
>
>
> Johannes Kröger wrote:
>
> > Hey Giuseppe,
>
> > yay, little morning programming practise for me. :)
>
> > If I read it correctly it fails with any column name shorter than 8
> characters, weird how this was never catched before (or I am just on the
> wrong path).
>
> > My line numbers are slightly off but I assume the following block is
> where it errors for you:
>  if (count<10) columnName = columnName.substring(0,8) + "_" + count;  else
> columnName = columnName.substring(0,8) + count;
>
> > The hardcoded 8 is a problem here. A few lines above columnName is
> defined as:
>  columnName = columnName.substring(0,Math.min(columnName.length(), 10));
> Names will be truncated to a maximum of 10 characters here or stay as they
> are if they were <= 10 already.
>
> > Basically what seems to happen here is this:
>  // A String with less than 8 characters  String test = "1234567";  //
> Truncate to the shorter of its length or 10, here 7 so no truncation  test
> = test.substring(0,Math.min(test.length(), 10));  // Extract the substring
> up to index 8 (including)  test = test.substring(0,8);  // test's highest
> index is 7, so it's OOB
>
> > The substring operations within the if/else need to take care of strings
> shorter than 8 characters and truncate accordingly.
>
> > Cheers, Hannes
>
> > PS: SHP begone!
>
> > PPS: It will also fail rather badly if there are more than 99
> identically truncated names ;)
>
> > PPPS: Wouldn't it result in ambiguity if the truncation from 10 to 8
> characters leads to the same string of previously different names?
> abcdefghij and abcdefghik would both result in abcdefgh as "truncated +
> count" column name.
>
> On Tue, 16 Jun 2015 07:58:53 +
> jump-pilot-devel-requ...@lists.sourceforge.net wrote:
>
> > Date: Tue, 16 Jun 2015 09:58:47 +0200
> > From: Giuseppe Aruta 
> > Subject: [JPP-Devel] Bug on saving layer to SHP
> > To: OpenJump develop and use 
> > Message-ID:
> >   <
> ca+alwnxx+4cujfs75p0sdfsvhlrdq+ddjjk90ht8y-ixu5r...@mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hi,
> > this is the message I had when I tired to save a vector layer to
> > Shapefile:
> >
> > java.lang.StringIndexOutOfBoundsException: String index out of range:
> > 8 at java.lang.String.substring(String.java:1907)
> > at
> >
> com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
> > at
> >
> com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
> > at
> >
> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
> > at
> >
> com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
> > at
> >
> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
> > at java.lang.Thread.run(Thread.java:744)
> >
> > Saving to JML works fine
> > Peppe
>
>
> --
> ___
> 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


Re: [JPP-Devel] Bug on saving layer to SHP

2015-06-16 Thread Michaël Michaud
Hi,

Good catch ! and good description Hannes.

Should be fixed in r4496, including PPS and PPPS,

Michaël

Le 16/06/2015 10:57, Johannes Kröger a écrit :
> Hey Giuseppe,
>
> yay, little morning programming practise for me. :)
>
> If I read it correctly it fails with any column name shorter than 8
> characters, weird how this was never catched before (or I am just on
> the wrong path).
>
> My line numbers are slightly off but I assume the following block is
> where it errors for you:
>   if (count<10) columnName = columnName.substring(0,8) + "_" + count;
>   else columnName = columnName.substring(0,8) + count;
>
> The hardcoded 8 is a problem here. A few lines above columnName is
> defined as:
>   columnName = columnName.substring(0,Math.min(columnName.length(), 10));
> Names will be truncated to a maximum of 10 characters here or stay as
> they are if they were <= 10 already.
>
> Basically what seems to happen here is this:
>   // A String with less than 8 characters
>   String test = "1234567";
>   // Truncate to the shorter of its length or 10, here 7 so no truncation
>   test = test.substring(0,Math.min(test.length(), 10));
>   // Extract the substring up to index 8 (including)
>   test = test.substring(0,8);
>   // test's highest index is 7, so it's OOB
>
> The substring operations within the if/else need to take care of
> strings shorter than 8 characters and truncate accordingly.
>
> Cheers, Hannes
>
> PS: SHP begone!
>
> PPS: It will also fail rather badly if there are more than 99
> identically truncated names ;)
>
> PPPS: Wouldn't it result in ambiguity if the truncation from 10 to 8
> characters leads to the same string of previously different names?
> abcdefghij and abcdefghik would both result in abcdefgh as "truncated +
> count" column name.
>
> On Tue, 16 Jun 2015 07:58:53 +
> jump-pilot-devel-requ...@lists.sourceforge.net wrote:
>
>> Date: Tue, 16 Jun 2015 09:58:47 +0200
>> From: Giuseppe Aruta 
>> Subject: [JPP-Devel] Bug on saving layer to SHP
>> To: OpenJump develop and use 
>> Message-ID:
>>  
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi,
>> this is the message I had when I tired to save a vector layer to
>> Shapefile:
>>
>> java.lang.StringIndexOutOfBoundsException: String index out of range:
>> 8 at java.lang.String.substring(String.java:1907)
>>  at
>> com.vividsolutions.jump.io.ShapefileWriter.writeDbf(ShapefileWriter.java:435)
>>  at
>> com.vividsolutions.jump.io.ShapefileWriter.write(ShapefileWriter.java:295)
>>  at
>> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeUpdate(ReaderWriterFileDataSource.java:73)
>>  at
>> com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:28)
>>  at
>> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152)
>>  at java.lang.Thread.run(Thread.java:744)
>>
>> Saving to JML works fine
>> Peppe
> --
> ___
> 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