From: Sandro Santilli Date: Tue, 27 Mar 2012 07:01:16 +0000 (+0000) Subject: Drop pljava (#1411) X-Git-Tag: 2.0.0rc1~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1888458cdf0d1a4ed38f44f2432b7dd1787a4a41;p=postgis Drop pljava (#1411) git-svn-id: http://svn.osgeo.org/postgis/trunk@9551 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/java/pljava/README.txt b/java/pljava/README.txt deleted file mode 100644 index 68f2ef2d8..000000000 --- a/java/pljava/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -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. diff --git a/java/pljava/build.xml b/java/pljava/build.xml deleted file mode 100644 index d0b7a4986..000000000 --- a/java/pljava/build.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Build the api jar and JNI headers for the navi java api - - $Id$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/pljava/functions.sql b/java/pljava/functions.sql deleted file mode 100644 index 9fe6f1fd0..000000000 --- a/java/pljava/functions.sql +++ /dev/null @@ -1,21 +0,0 @@ - --- 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 diff --git a/java/pljava/install.sh b/java/pljava/install.sh deleted file mode 100755 index 5e6c8af5f..000000000 --- a/java/pljava/install.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -cat < 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; - } - } -} diff --git a/java/pljava/update.sh b/java/pljava/update.sh deleted file mode 100755 index 1aa804329..000000000 --- a/java/pljava/update.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -ant 1>&2 - -cat <