+++ /dev/null
-Pre-Alpha support for PLJava.
-
-!!! This code will not work against any released pljava version. See pljava developer list
-archive for discussion of the changes needed in pljava for this code to work. Let's hope all
-the fixes get into the next pljava release.
-
-Put pljava.jar and jts-1.7.1.jar into lib/ directory, then run ant.
+++ /dev/null
-<?xml version="1.0"?>
-<!-- PostGIS PLJava support
- (C) 2006 Markus Schaber <schabi@logix-tt.com>
-
-This library is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free
-Software Foundation, either version 2.1 of the License.
-
-This library is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
-http://www.gnu.org.
-
-$Id$
--->
-<project name="Postgis-PLJava" default="all">
- <property file="build.properties" />
- <description>
- Build the api jar and JNI headers for the navi java api
-
- $Id$
- </description>
-
- <property name="source.dir" value="src" />
- <property name="class.dir" value="bin" />
- <property name="jar.file" value="postgis_pljava.jar" />
- <path id="buildcp"><fileset dir="lib" includes="*.jar"/></path>
-
- <target name="all" depends="jar" description="build all">
-
- </target>
- <target name="clean" description="clean the whole mess up">
- <delete dir="${class.dir}" includeemptydirs="true" />
- <delete file="${jar.file}" />
- </target>
-
- <target name="prepare">
- <mkdir dir="${class.dir}" />
- </target>
-
- <target name="compile" depends="prepare">
- <javac srcdir="${source.dir}"
- destdir="${class.dir}"
- debug="${debug}"
- deprecation="${deprecation}"
- optimize="${optimize}"
- source="1.4"
- target="1.4" classpathref="buildcp"/>
- </target>
-
- <target name="jar"
- depends="compile"
- description="create the java api package">
- <jar basedir="${class.dir}" destfile="${jar.file}">
- </jar>
- </target>
-
- <target name="properties"
- description="Output all properties to stdout - build file debugging help">
- <echoproperties />
- </target>
-
-</project>
-
+++ /dev/null
-
--- Create a function to call the java function
-CREATE OR REPLACE FUNCTION public.helloworld()
- RETURNS "varchar" AS
- 'org.postgis.pljava.HelloWorld.helloWorld'
- LANGUAGE 'java' VOLATILE;
-
-SELECT sqlj.drop_type_mapping('public.geometry');
-
-SELECT sqlj.add_type_mapping('geometry', 'org.postgis.pljava.PLJGeometry');
-
-CREATE OR REPLACE FUNCTION public.getSize(geometry)
- RETURNS "int4" AS
- 'org.postgis.pljava.HelloWorld.getSize'
- LANGUAGE 'java' IMMUTABLE STRICT;
-
-CREATE OR REPLACE FUNCTION public.getString(geometry)
- RETURNS "text" AS
- 'org.postgis.pljava.HelloWorld.getString'
- LANGUAGE 'java' IMMUTABLE STRICT;
-
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-
-cat <<EOF
-
-set search_path to public;
-
-SELECT sqlj.install_jar('file://${PWD}/postgis_pljava.jar', 'postgis_pljava_jar', false);
-SELECT sqlj.install_jar('file://${PWD}/lib/jts-1.7.1.jar', 'jts_171_jar', false);
-
-
--- Set the class path on the schema you are using.
-SELECT sqlj.set_classpath('public', 'postgis_pljava_jar:jts_171_jar');
-
-EOF
-
-cat functions.sql
+++ /dev/null
-package org.postgis.pljava;
-
-import java.sql.SQLException;
-
-import org.postgresql.pljava.Session;
-
-public class Aggregates {
- public static void test() throws SQLException {
- Session a = org.postgresql.pljava.SessionManager.current();
-
- a.hashCode();
- }
-}
+++ /dev/null
-package org.postgis.pljava;
-
-public class HelloWorld {
- public static String helloWorld() {
- return "Hello Postgis-World";
- }
-
- public static int getSize(PLJGeometry geom) {
- return geom.geom.getNumPoints();
- }
-
- public static String getString(PLJGeometry geom) {
- return geom.toString();
- }
-}
+++ /dev/null
-/*
- * PLJGeometry
- *
- * PostGIS datatype definition for PLJava
- *
- * (C) 2006 Markus Schaber, markus.schaber@logix-tt.com
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation, either version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
- * http://www.gnu.org.
- *
- * $Id$
- */
-package org.postgis.pljava;
-
-import java.sql.SQLData;
-import java.sql.SQLException;
-import java.sql.SQLInput;
-import java.sql.SQLOutput;
-
-import com.vividsolutions.jts.geom.CoordinateSequenceFactory;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.GeometryFactory;
-import com.vividsolutions.jts.geom.PrecisionModel;
-import com.vividsolutions.jts.geom.impl.PackedCoordinateSequenceFactory;
-
-public class PLJGeometry implements SQLData {
- final static PrecisionModel prec = new PrecisionModel();
-
- final static CoordinateSequenceFactory csfac = PackedCoordinateSequenceFactory.DOUBLE_FACTORY;
-
- final static GeometryFactory geofac = new GeometryFactory(prec, 0, csfac);
-
- final static PLJtsParser parser = new PLJtsParser();
- final static PLJtsWriter writer = new PLJtsWriter();
-
- public static final String m_typeName="public.geometry";
-
- public Geometry geom;
-
- public String getSQLTypeName() {
- return m_typeName;
- }
-
- public void readSQL(SQLInput stream, String typeName) throws SQLException {
- checkType(typeName);
-
- // skip length marker
- stream.readInt();
-
- // read the Geometry
- this.geom = parser.parseGeometry(stream);
- }
-
- /** Check whether our given type is actually the one we can handle */
- private static void checkType(String typeName) throws SQLException {
- if (!m_typeName.equalsIgnoreCase(typeName)) {
- throw new SQLException("parser for "+m_typeName+" cannot parse type "+typeName+"!");
- }
- }
-
-
- public void writeSQL(SQLOutput stream) throws SQLException {
- // write size marker
- stream.writeInt(writer.estimateBytes(geom));
-
- // write geometry
- writer.writeGeometry(geom, stream);
- }
-}
+++ /dev/null
-/*
- * JtsBinaryParser.java
- *
- * Binary Parser for JTS - relies on org.postgis V1.0.0+ package.
- *
- * (C) 2005 Markus Schaber, markus.schaber@logix-tt.com
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation, either version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
- * http://www.gnu.org.
- *
- * $Id$
- */
-package org.postgis.pljava;
-
-import java.sql.SQLException;
-import java.sql.SQLInput;
-
-
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.CoordinateSequence;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.GeometryCollection;
-import com.vividsolutions.jts.geom.LineString;
-import com.vividsolutions.jts.geom.LinearRing;
-import com.vividsolutions.jts.geom.MultiLineString;
-import com.vividsolutions.jts.geom.MultiPoint;
-import com.vividsolutions.jts.geom.MultiPolygon;
-import com.vividsolutions.jts.geom.Point;
-import com.vividsolutions.jts.geom.Polygon;
-import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence;
-
-/**
- * Parse binary representation of geometries. Currently, only text rep (hexed)
- * implementation is tested.
- *
- * It should be easy to add char[] and CharSequence ByteGetter instances,
- * although the latter one is not compatible with older jdks.
- *
- * I did not implement real unsigned 32-bit integers or emulate them with long,
- * as both java Arrays and Strings currently can have only 2^31-1 elements
- * (bytes), so we cannot even get or build Geometries with more than approx.
- * 2^28 coordinates (8 bytes each).
- *
- * @author Markus Schaber, markus.schaber@logix-tt.com
- *
- */
-public class PLJtsParser {
-
- /** Parse a geometry
- * @throws SQLException */
- public Geometry parseGeometry(SQLInput data) throws SQLException {
- return parseGeometry(data, 0, false);
- }
-
- /** Parse with a known geometry factory
- * @throws SQLException */
- protected Geometry parseGeometry(SQLInput data, int srid, boolean inheritSrid) throws SQLException {
- int typeword = data.readByte() & 0xFF;
-
- int realtype = typeword & 0x0F; // cut off high flag bits
-
- boolean haveBBox = (typeword & 0x80) != 0;
- boolean haveS = (typeword & 0x40) != 0;
- boolean haveZ = (typeword & 0x20) != 0;
- boolean haveM = (typeword & 0x10) != 0;
-
- if (haveBBox) {
- // skip bbox, currently ignored
- data.readFloat();
- data.readFloat();
- data.readFloat();
- data.readFloat();
- }
-
- if (haveS) {
- int newsrid = data.readInt();
- if (inheritSrid && newsrid != srid) {
- throw new IllegalArgumentException("Inconsistent srids in complex geometry: " + srid + ", " + newsrid);
- } else {
- srid = newsrid;
- }
- } else if (!inheritSrid) {
- srid = Geometry.UNKNOWN_SRID;
- }
-
- Geometry result;
- switch (realtype) {
- case org.postgis.Geometry.POINT:
- result = parsePoint(data, haveZ, haveM);
- break;
- case org.postgis.Geometry.LINESTRING:
- result = parseLineString(data, haveZ, haveM);
- break;
- case org.postgis.Geometry.POLYGON:
- result = parsePolygon(data, haveZ, haveM, srid);
- break;
- case org.postgis.Geometry.MULTIPOINT:
- result = parseMultiPoint(data, srid);
- break;
- case org.postgis.Geometry.MULTILINESTRING:
- result = parseMultiLineString(data, srid);
- break;
- case org.postgis.Geometry.MULTIPOLYGON:
- result = parseMultiPolygon(data, srid);
- break;
- case org.postgis.Geometry.GEOMETRYCOLLECTION:
- result = parseCollection(data, srid);
- break;
- default:
- throw new IllegalArgumentException("Unknown Geometry Type!");
- }
-
- result.setSRID(srid);
-
- return result;
- }
-
- private Point parsePoint(SQLInput data, boolean haveZ, boolean haveM) throws SQLException {
- double X = data.readDouble();
- double Y = data.readDouble();
- Point result;
- if (haveZ) {
- double Z = data.readDouble();
- result = PLJGeometry.geofac.createPoint(new Coordinate(X, Y, Z));
- } else {
- result = PLJGeometry.geofac.createPoint(new Coordinate(X, Y));
- }
-
- if (haveM) { // skip M value
- data.readDouble();
- }
-
- return result;
- }
-
- /** Parse an Array of "full" Geometries
- * @throws SQLException */
- private void parseGeometryArray(SQLInput data, Geometry[] container, int srid) throws SQLException {
- for (int i = 0; i < container.length; i++) {
- container[i] = parseGeometry(data, srid, true);
- }
- }
-
- /**
- * Parse an Array of "slim" Points (without endianness and type, part of
- * LinearRing and Linestring, but not MultiPoint!
- *
- * @param haveZ
- * @param haveM
- * @throws SQLException
- */
- private CoordinateSequence parseCS(SQLInput data, boolean haveZ, boolean haveM) throws SQLException {
- int count = data.readInt();
- int dims = haveZ ? 3 : 2;
- CoordinateSequence cs = new PackedCoordinateSequence.Double(count, dims);
-
- for (int i = 0; i < count; i++) {
- for (int d = 0; d < dims; d++) {
- cs.setOrdinate(i, d, data.readDouble());
- }
- if (haveM) { // skip M value
- data.readDouble();
- }
- }
- return cs;
- }
-
- private MultiPoint parseMultiPoint(SQLInput data, int srid) throws SQLException {
- Point[] points = new Point[data.readInt()];
- parseGeometryArray(data, points, srid);
- return PLJGeometry.geofac.createMultiPoint(points);
- }
-
- private LineString parseLineString(SQLInput data, boolean haveZ, boolean haveM) throws SQLException {
- return PLJGeometry.geofac.createLineString(parseCS(data, haveZ, haveM));
- }
-
- private LinearRing parseLinearRing(SQLInput data, boolean haveZ, boolean haveM) throws SQLException {
- return PLJGeometry.geofac.createLinearRing(parseCS(data, haveZ, haveM));
- }
-
- private Polygon parsePolygon(SQLInput data, boolean haveZ, boolean haveM, int srid) throws SQLException {
- int holecount = data.readInt() - 1;
- LinearRing[] rings = new LinearRing[holecount];
- LinearRing shell = parseLinearRing(data, haveZ, haveM);
- shell.setSRID(srid);
- for (int i = 0; i < holecount; i++) {
- rings[i] = parseLinearRing(data, haveZ, haveM);
- rings[i].setSRID(srid);
- }
- return PLJGeometry.geofac.createPolygon(shell, rings);
- }
-
- private MultiLineString parseMultiLineString(SQLInput data, int srid) throws SQLException {
- int count = data.readInt();
- LineString[] strings = new LineString[count];
- parseGeometryArray(data, strings, srid);
- return PLJGeometry.geofac.createMultiLineString(strings);
- }
-
- private MultiPolygon parseMultiPolygon(SQLInput data, int srid) throws SQLException {
- int count = data.readInt();
- Polygon[] polys = new Polygon[count];
- parseGeometryArray(data, polys, srid);
- return PLJGeometry.geofac.createMultiPolygon(polys);
- }
-
- private GeometryCollection parseCollection(SQLInput data, int srid) throws SQLException {
- int count = data.readInt();
- Geometry[] geoms = new Geometry[count];
- parseGeometryArray(data, geoms, srid);
- return PLJGeometry.geofac.createGeometryCollection(geoms);
- }
-}
+++ /dev/null
-/*
- * JtsBinaryWriter.java
- *
- * PostGIS extension for PostgreSQL JDBC driver - Binary Writer
- *
- * (C) 2005 Markus Schaber, markus.schaber@logix-tt.com
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation, either version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
- * http://www.gnu.org.
- *
- * $Id$
- */
-package org.postgis.pljava;
-
-import java.sql.SQLException;
-import java.sql.SQLOutput;
-
-import com.vividsolutions.jts.geom.CoordinateSequence;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.GeometryCollection;
-import com.vividsolutions.jts.geom.LineString;
-import com.vividsolutions.jts.geom.MultiLineString;
-import com.vividsolutions.jts.geom.MultiPoint;
-import com.vividsolutions.jts.geom.MultiPolygon;
-import com.vividsolutions.jts.geom.Point;
-import com.vividsolutions.jts.geom.Polygon;
-
-
-/**
- * Create binary representation of geometries. Currently, only text rep (hexed)
- * implementation is tested. Supports only 2 dimensional geometries.
- *
- * It should be easy to add char[] and CharSequence ByteGetter instances,
- * although the latter one is not compatible with older jdks.
- *
- * I did not implement real unsigned 32-bit integers or emulate them with long,
- * as both java Arrays and Strings currently can have only 2^31-1 elements
- * (bytes), so we cannot even get or build Geometries with more than approx.
- * 2^28 coordinates (8 bytes each).
- *
- * @author markus.schaber@logi-track.com
- *
- */
-public class PLJtsWriter {
-
- public void writeBinary(Geometry geom, SQLOutput dest) throws SQLException {
- writeGeometry(geom, dest);
- }
-
- /** Parse a geometry starting at offset.
- * @throws SQLException */
- protected void writeGeometry(Geometry geom, SQLOutput dest) throws SQLException {
- // TODO: Add bbox
- // TODO: Add proper handling of Measures
-
-
- final int dimension = getCoordDim(geom);
- if (dimension < 2 || dimension > 4) {
- throw new IllegalArgumentException("Unsupported geometry dimensionality: " + dimension);
- }
-
- // write typeword
- final int plaintype = getWKBType(geom);
- byte typeword = (byte)plaintype;
- if (dimension == 3 || dimension == 4) {
- typeword |= 0x20;
- }
- if (dimension == 4) {
- typeword |= 0x10;
- }
- if (checkSrid(geom)) {
- typeword |= 0x40;
- }
-
- dest.writeByte(typeword);
-
- if (checkSrid(geom)) {
- dest.writeInt(geom.getSRID());
- }
-
- switch (plaintype) {
- case org.postgis.Geometry.POINT:
- writePoint((Point) geom, dest);
- break;
- case org.postgis.Geometry.LINESTRING:
- writeLineString((LineString) geom, dest);
- break;
- case org.postgis.Geometry.POLYGON:
- writePolygon((Polygon) geom, dest);
- break;
- case org.postgis.Geometry.MULTIPOINT:
- writeMultiPoint((MultiPoint) geom, dest);
- break;
- case org.postgis.Geometry.MULTILINESTRING:
- writeMultiLineString((MultiLineString) geom, dest);
- break;
- case org.postgis.Geometry.MULTIPOLYGON:
- writeMultiPolygon((MultiPolygon) geom, dest);
- break;
- case org.postgis.Geometry.GEOMETRYCOLLECTION:
- writeCollection((GeometryCollection) geom, dest);
- break;
- default:
- throw new IllegalArgumentException("Unknown Geometry Type: " + plaintype);
- }
- }
-
- public static int getWKBType(Geometry geom) {
- if (geom instanceof Point) {
- return org.postgis.Geometry.POINT;
- } else if (geom instanceof com.vividsolutions.jts.geom.LineString) {
- return org.postgis.Geometry.LINESTRING;
- } else if (geom instanceof com.vividsolutions.jts.geom.Polygon) {
- return org.postgis.Geometry.POLYGON;
- } else if (geom instanceof MultiPoint) {
- return org.postgis.Geometry.MULTIPOINT;
- } else if (geom instanceof MultiLineString) {
- return org.postgis.Geometry.MULTILINESTRING;
- } else if (geom instanceof com.vividsolutions.jts.geom.MultiPolygon) {
- return org.postgis.Geometry.MULTIPOLYGON;
- } else if (geom instanceof com.vividsolutions.jts.geom.GeometryCollection) {
- return org.postgis.Geometry.GEOMETRYCOLLECTION;
- } else {
- throw new IllegalArgumentException("Unknown Geometry Type: " + geom.getClass().getName());
- }
- }
-
- /**
- * Writes a "slim" Point (without endiannes, srid ant type, only the
- * ordinates and measure. Used by writeGeometry.
- * @throws SQLException
- */
- private void writePoint(Point geom, SQLOutput dest) throws SQLException {
- writeCoordinates(geom.getCoordinateSequence(), getCoordDim(geom), dest);
- }
-
- /**
- * Write a Coordinatesequence, part of LinearRing and Linestring, but not
- * MultiPoint!
- * @throws SQLException
- */
- private void writeCoordinates(CoordinateSequence seq, int dims, SQLOutput dest) throws SQLException {
- for (int i = 0; i < seq.size(); i++) {
- for (int d = 0; d < dims; d++) {
- dest.writeDouble(seq.getOrdinate(i, d));
- }
- }
- }
-
- private void writeMultiPoint(MultiPoint geom, SQLOutput dest) throws SQLException {
- dest.writeInt(geom.getNumPoints());
- for (int i = 0; i < geom.getNumPoints(); i++) {
- writeGeometry(geom.getGeometryN(i), dest);
- }
- }
-
- private void writeLineString(LineString geom, SQLOutput dest) throws SQLException {
- dest.writeInt(geom.getNumPoints());
- writeCoordinates(geom.getCoordinateSequence(), getCoordDim(geom), dest);
- }
-
- private void writePolygon(Polygon geom, SQLOutput dest) throws SQLException {
- dest.writeInt(geom.getNumInteriorRing() + 1);
- writeLineString(geom.getExteriorRing(), dest);
- for (int i = 0; i < geom.getNumInteriorRing(); i++) {
- writeLineString(geom.getInteriorRingN(i), dest);
- }
- }
-
- private void writeMultiLineString(MultiLineString geom, SQLOutput dest) throws SQLException {
- writeGeometryArray(geom, dest);
- }
-
- private void writeMultiPolygon(MultiPolygon geom, SQLOutput dest) throws SQLException {
- writeGeometryArray(geom, dest);
- }
-
- private void writeCollection(GeometryCollection geom, SQLOutput dest) throws SQLException {
- writeGeometryArray(geom, dest);
- }
-
- private void writeGeometryArray(Geometry geom, SQLOutput dest) throws SQLException {
- dest.writeInt(geom.getNumGeometries());
- for (int i = 0; i < geom.getNumGeometries(); i++) {
- writeGeometry(geom.getGeometryN(i), dest);
- }
- }
-
- /** Estimate how much bytes a geometry will need in WKB. */
- protected int estimateBytes(Geometry geom) {
- // Todo: include bbox
- int result = 0;
-
- // write type byte
- result += 1;
-
- if (checkSrid(geom)) {
- result += 4;
- }
-
- switch (getWKBType(geom)) {
- case org.postgis.Geometry.POINT:
- result += estimatePoint((Point) geom);
- break;
- case org.postgis.Geometry.LINESTRING:
- result += estimateLineString((LineString) geom);
- break;
- case org.postgis.Geometry.POLYGON:
- result += estimatePolygon((Polygon) geom);
- break;
- case org.postgis.Geometry.MULTIPOINT:
- result += estimateMultiPoint((MultiPoint) geom);
- break;
- case org.postgis.Geometry.MULTILINESTRING:
- result += estimateMultiLineString((MultiLineString) geom);
- break;
- case org.postgis.Geometry.MULTIPOLYGON:
- result += estimateMultiPolygon((MultiPolygon) geom);
- break;
- case org.postgis.Geometry.GEOMETRYCOLLECTION:
- result += estimateCollection((GeometryCollection) geom);
- break;
- default:
- throw new IllegalArgumentException("Unknown Geometry Type: " + getWKBType(geom));
- }
- return result;
- }
-
- private boolean checkSrid(Geometry geom) {
- final int srid = geom.getSRID();
- // SRID is default 0 with jts geometries
- return (srid > 0);
- }
-
- private int estimatePoint(Point geom) {
- return 8 * getCoordDim(geom);
- }
-
- /** Write an Array of "full" Geometries */
- private int estimateGeometryArray(Geometry container) {
- int result = 0;
- for (int i = 0; i < container.getNumGeometries(); i++) {
- result += estimateBytes(container.getGeometryN(i));
- }
- return result;
- }
-
- /**
- * Estimate an Array of "slim" Points (without endianness and type, part of
- * LinearRing and Linestring, but not MultiPoint!
- */
- private int estimatePointArray(int length, Point example) {
- // number of points
- int result = 4;
-
- // And the amount of the points itsself, in consistent geometries
- // all points have equal size.
- if (length > 0) {
- result += length * estimatePoint(example);
- }
- return result;
- }
-
- /** Estimate an array of "fat" Points */
- private int estimateMultiPoint(MultiPoint geom) {
- // int size
- int result = 4;
- if (geom.getNumGeometries() > 0) {
- // We can shortcut here, compared to estimateGeometryArray, as all
- // subgeoms have the same fixed size
- result += geom.getNumGeometries() * estimateBytes(geom.getGeometryN(0));
- }
- return result;
- }
-
- private int estimateLineString(LineString geom) {
- if (geom == null || geom.getNumGeometries() == 0) {
- return 0;
- } else {
- return estimatePointArray(geom.getNumPoints(), geom.getStartPoint());
- }
- }
-
- private int estimatePolygon(Polygon geom) {
- // int length
- int result = 4;
- result += estimateLineString(geom.getExteriorRing());
- for (int i = 0; i < geom.getNumInteriorRing(); i++) {
- result += estimateLineString(geom.getInteriorRingN(i));
- }
- return result;
- }
-
- private int estimateMultiLineString(MultiLineString geom) {
- // 4-byte count + subgeometries
- return 4 + estimateGeometryArray(geom);
- }
-
- private int estimateMultiPolygon(MultiPolygon geom) {
- // 4-byte count + subgeometries
- return 4 + estimateGeometryArray(geom);
- }
-
- private int estimateCollection(GeometryCollection geom) {
- // 4-byte count + subgeometries
- return 4 + estimateGeometryArray(geom);
- }
-
- public static final int getCoordDim(Geometry geom) {
- // TODO: Fix geometries with more dimensions
- // geom.getFactory().getCoordinateSequenceFactory()
- if (geom == null) {
- return 0;
- } else {
- return 2;
- }
- }
-}
+++ /dev/null
-#!/bin/sh
-
-ant 1>&2
-
-cat <<EOF
-
-set search_path to public;
-
-SELECT sqlj.replace_jar('file://${PWD}/postgis_pljava.jar', 'postgis_pljava_jar', false);
-
-EOF
-
-cat functions.sql