[prev in list] [next in list] [prev in thread] [next in thread]
List: postgis-users
Subject: Re: [postgis-users] Bug in org.postgis.LineString concat() from Java API 1.3.3
From: Paul Ramsey <pramsey () opengeo ! org>
Date: 2012-01-26 16:24:06
Message-ID: CACowWR3iOvr-r88rafzQnJGTvb+MHOVJL3Sf1_j0N6ZBohwxcg () mail ! gmail ! com
[Download RAW message or body]
Thanks, I agree w/ your analysis, patched.
On Thu, Jan 26, 2012 at 2:20 AM, Innerebner Markus
<markus.innerebner@inf.unibz.it> wrote:
> Hi all,
>
> for me this looks like an error:
>
> postgis.jdbc.LineString method concat (line70)
>
> WRONG:
> int count = points.length + points.length - (cutPoint ? 1 : 0);
>
> CORRECT:
> int count = points.length + opoints.length - (cutPoint ? 1 : 0);
>
> can you check this please?
>
> thanks Markus
>
> I am using the version 1.3.3 from the maven repository
>
> <dependency>
> <groupId>org.postgis</groupId>
> <artifactId>postgis-jdbc</artifactId>
> <version>1.3.3</version>
> </dependency>
>
>
> /************** corrected ***/
>
> public LineString concat(LineString other) {
> Point[] points = this.getPoints();
> Point[] opoints = other.getPoints();
>
> boolean cutPoint = this.getLastPoint() == null
> || this.getLastPoint().equals(other.getFirstPoint());
> int count = points.length + opoints.length - (cutPoint ? 1 : 0);
> Point[] p = new Point[count];
>
> // Maybe we should use System.arrayCopy here?
> int i, j;
> for (i = 0; i < points.length; i++) {
> p[i] = points[i];
> }
> if (!cutPoint) {
> p[i++] = other.getFirstPoint();
> }
> for (j = 1; j < opoints.length; j++, i++) {
> p[i] = opoints[j];
> }
> return new LineString(p);
> }
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic