Bug in Sextante dissolve algorithm

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in Sextante dissolve algorithm

Olivier Bedel-2
Hi list,

Using the Sextante dissolve algorithm, i noticed some strange errors
linked to field aggregation parameters. Looking at the sextante code, i
think i found a bug in the "getGroupings" function in the
"DissolveAlgorithm" class.

Original code is :

/************************************************************************************/

private Grouping[] getGroupings(final String sGroupings) throws GeoAlgorithmExecutionException {

       if (sGroupings.trim().equals("")) {
          return new Grouping[0];
       }
       try {
          final String[] sTokens = sGroupings.split(",");
          if (sTokens.length % 2 != 0) {
             throw new GeoAlgorithmExecutionException("Wrong groupings");
          }
          final Grouping[] groupings = new Grouping[sTokens.length / 2];

          int iGrouping = 0;
          for (int i = 0; i<  sTokens.length - 1; i++) {
             groupings[iGrouping] = new Grouping();
             groupings[iGrouping].field = Integer.parseInt(sTokens[i]);
             if ((groupings[iGrouping].field>= m_LayerIn.getFieldCount()) || (groupings[iGrouping].field<  0)) {
                throw new GeoAlgorithmExecutionException("Wrong groupings");
             }
             i++;
             groupings[iGrouping].function = Integer.parseInt(sTokens[i]);
             if ((groupings[iGrouping].field>  4) || (groupings[iGrouping].field<  0)) {
                throw new GeoAlgorithmExecutionException("Wrong groupings");
             }
             iGrouping++;
          }
          return groupings;
       }
       catch (final Exception e) {
          throw new GeoAlgorithmExecutionException("Wrong groupings");
       }



    }

/************************************************************************************/


but to my mind should be like :

/************************************************************************************/

private Grouping[] getGroupings(final String sGroupings) throws GeoAlgorithmExecutionException {

       if (sGroupings.trim().equals("")) {

         return new Grouping[0];

       }

       try {

          final String[] sTokens = sGroupings.split(",");

          if (sTokens.length % 2 != 0) {

             throw new GeoAlgorithmExecutionException("Wrong groupings");

          }

          final Grouping[] groupings = new Grouping[sTokens.length / 2];

          int iGrouping = 0;

          for (int i = 0; i<  sTokens.length; i++) {

             groupings[iGrouping] = new Grouping();

             groupings[iGrouping].field = Integer.parseInt(sTokens[i]);

             if ((groupings[iGrouping].field>= m_LayerIn.getFieldCount()) || (groupings[iGrouping].field<  0)) {

                throw new GeoAlgorithmExecutionException("Wrong groupings");

             }

             i++;

             groupings[iGrouping].function = Integer.parseInt(sTokens[i]);

             if ((groupings[iGrouping].function>  4) || (groupings[iGrouping].function<  0)) {

                throw new GeoAlgorithmExecutionException("Wrong groupings");

             }

             iGrouping++;

          }

          return groupings;

       }

       catch (final Exception e) {

          throw new GeoAlgorithmExecutionException("Wrong groupings");

       }

    }
/************************************************************************************/

Best regards,
Olivier.

--
Olivier BEDEL

ALKANTE SAS
Ingénieur R&D SIG
1, rue du Chêne Morand
35 510 Cesson-Sévigné
Bur: + 33 (0) 2 99 22 25 70
fax : + 33 (0) 2 99 32 12 76

_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: Bug in Sextante dissolve algorithm

volaya
Olivier

this line is clearly wrong, you are right:

            if ((groupings[iGrouping].field>  4) ||>
(groupings[iGrouping].field<  0)) {


However, could you explain more in detail the problems you are having
or send me the layer you are using? Just in case this fix doesn't
solve your problem, so I can check it and try to fix it.

Regards.

Victor
_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: Bug in Sextante dissolve algorithm

Olivier Bedel-2
Hi Victor,

In fact, I got a "Wrong grouping" error when I tried to apply a grouping
function to a field which pos was greater than 4 or 5.
I rebuilt the vectorTools.jar with the correction i sent and it solved
the problem for me. I do not notice any side effects but I can look for
the layer I used for testing and send it to you if you want to make tests

Regards,
Olivier.

Le 20/05/2011 11:37, Victor Olaya a écrit :

> Olivier
>
> this line is clearly wrong, you are right:
>
>              if ((groupings[iGrouping].field>    4) ||>
> (groupings[iGrouping].field<    0)) {
>
>
> However, could you explain more in detail the problems you are having
> or send me the layer you are using? Just in case this fix doesn't
> solve your problem, so I can check it and try to fix it.
>
> Regards.
>
> Victor


--
Olivier BEDEL

ALKANTE SAS
Ingénieur R&D SIG
1, rue du Chêne Morand
35 510 Cesson-Sévigné
Bur: + 33 (0) 2 99 22 25 70
fax : + 33 (0) 2 99 32 12 76

_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: Bug in Sextante dissolve algorithm

volaya
If it solves your problem, then it's ok. If you find any further
problems, just tell me and I will try to help you.

Regards

Victor


2011/5/20 Olivier Bedel <[hidden email]>:

> Hi Victor,
>
> In fact, I got a "Wrong grouping" error when I tried to apply a grouping
> function to a field which pos was greater than 4 or 5.
> I rebuilt the vectorTools.jar with the correction i sent and it solved the
> problem for me. I do not notice any side effects but I can look for the
> layer I used for testing and send it to you if you want to make tests
>
> Regards,
> Olivier.
>
> Le 20/05/2011 11:37, Victor Olaya a écrit :
>>
>> Olivier
>>
>> this line is clearly wrong, you are right:
>>
>>             if ((groupings[iGrouping].field>    4) ||>
>> (groupings[iGrouping].field<    0)) {
>>
>>
>> However, could you explain more in detail the problems you are having
>> or send me the layer you are using? Just in case this fix doesn't
>> solve your problem, so I can check it and try to fix it.
>>
>> Regards.
>>
>> Victor
>
>
> --
> Olivier BEDEL
>
> ALKANTE SAS
> Ingénieur R&D SIG
> 1, rue du Chêne Morand
> 35 510 Cesson-Sévigné
> Bur: + 33 (0) 2 99 22 25 70
> fax : + 33 (0) 2 99 32 12 76
>
>
_______________________________________________
gvSIG-desktop-devel mailing list
[hidden email]
https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel