[postgis-devel] Small jdbc2 patch

strk at refractions.net strk at refractions.net
Fri Jan 28 06:41:18 PST 2005


On Fri, Jan 28, 2005 at 03:04:52PM +0100, Markus Schaber wrote:
> Hi,
> 
> I attached a small patch to jdbc2 code. It changes three minor things:
> 
> - Add another item to the todo list.
> 
> - A small hack to cut traling ".0" on integer coordinates on WKT output.
>   As it makes things (slightly) slower, you can change Point.CUTINTS to
>   false. As it is static final, the compiler optimizer eliminates the
>   calls to cutint() altogether.
> 
> - Removed some debug variables from ValueGetter.java
> 
> 
> BTW, as I got no feedback from users up to now: Did anyone besides strk
> and me actually test or use this code? Are we the only PostGIS JDBC
> users altogether?

Count me out, I'm not a JDBC user at all, just tried to build it ;)
BTW: would you review the README before final release ?

--strk(committed);

> 
> Thanks,
> Markus
> -- 
> markus schaber | dipl. informatiker
> logi-track ag | rennweg 14-16 | ch 8001 zürich
> phone +41-43-888 62 52 | fax +41-43-888 62 53
> mailto:schabios at logi-track.com | www.logi-track.com

> Index: jdbc2/todo.txt
> ===================================================================
> RCS file: /home/cvs/postgis/postgis/jdbc2/todo.txt,v
> retrieving revision 1.1
> diff -u -r1.1 todo.txt
> --- jdbc2/todo.txt	19 Jan 2005 08:54:44 -0000	1.1
> +++ jdbc2/todo.txt	28 Jan 2005 14:00:44 -0000
> @@ -29,3 +29,6 @@
>  
>  - Possibly relicensing under LGPL
>  
> +- Possibly adding server side code to support plJava
> +  http://gborg.postgresql.org/project/pljava/projdisplay.php
> +
> Index: jdbc2/src/org/postgis/Point.java
> ===================================================================
> RCS file: /home/cvs/postgis/postgis/jdbc2/src/org/postgis/Point.java,v
> retrieving revision 1.1
> diff -u -r1.1 Point.java
> --- jdbc2/src/org/postgis/Point.java	19 Jan 2005 08:54:44 -0000	1.1
> +++ jdbc2/src/org/postgis/Point.java	28 Jan 2005 14:00:44 -0000
> @@ -6,6 +6,8 @@
>  
>  public class Point extends Geometry {
>  
> +    public static final boolean CUTINTS=true;
> +    
>      public int hashCode() {
>          return super.hashCode() ^ hashCode(x) ^ hashCode(y) ^ hashCode(z) ^ hashCode(m);
>      }
> @@ -109,15 +111,26 @@
>  
>      public void innerWKT(StringBuffer sb) {
>          sb.append(x);
> +        if (CUTINTS) cutint(sb);
>          sb.append(' ');
>          sb.append(y);
> +        if (CUTINTS) cutint(sb);
>          if (dimension == 3) {
>              sb.append(' ');
>              sb.append(z);
> +            if (CUTINTS) cutint(sb);
>          }
>          if (haveMeasure) {
>              sb.append(' ');
>              sb.append(m);
> +            if (CUTINTS) cutint(sb);
> +        }
> +    }
> +
> +    private static void cutint(StringBuffer sb) {
> +        int l = sb.length()-2;
> +        if ((sb.charAt(l+1)=='0')&&(sb.charAt(l)=='.')) {
> +            sb.setLength(l);
>          }
>      }
>  
> Index: jdbc2/src/org/postgis/binary/ValueGetter.java
> ===================================================================
> RCS file: /home/cvs/postgis/postgis/jdbc2/src/org/postgis/binary/ValueGetter.java,v
> retrieving revision 1.1
> diff -u -r1.1 ValueGetter.java
> --- jdbc2/src/org/postgis/binary/ValueGetter.java	19 Jan 2005 08:54:44 -0000	1.1
> +++ jdbc2/src/org/postgis/binary/ValueGetter.java	28 Jan 2005 14:00:44 -0000
> @@ -83,12 +83,7 @@
>          }
>  
>          protected int getInt(int index) {
> -            int hg = data.get(index + 3);
> -            int high = ((int) hg << 24);
> -            int hmed = ((int) data.get(index + 2) << 16);
> -            int lmed = ((int) data.get(index + 1) << 8);
> -            int low = (int) data.get(index);
> -            return high + hmed + lmed + low;
> +            return (data.get(index + 3) << 24) + (data.get(index + 2) << 16) + (data.get(index + 1) << 8) + data.get(index);
>          }
>  
>          protected long getLong(int index) {

> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel




More information about the postgis-devel mailing list