[postgis-users] Bug in org.postgis.LineString concat() from Java API 1.3.3
Paul Ramsey
pramsey at opengeo.org
Thu Jan 26 08:24:06 PST 2012
Thanks, I agree w/ your analysis, patched.
On Thu, Jan 26, 2012 at 2:20 AM, Innerebner Markus
<markus.innerebner at 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 at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list