diff --git a/nunaliit2-couch-onUpload/src/main/java/ca/carleton/gcrc/couch/onUpload/simplifyGeoms/GeometrySimplificationProcessImpl.java b/nunaliit2-couch-onUpload/src/main/java/ca/carleton/gcrc/couch/onUpload/simplifyGeoms/GeometrySimplificationProcessImpl.java index 4b9a8282d..6f0e5febd 100644 --- a/nunaliit2-couch-onUpload/src/main/java/ca/carleton/gcrc/couch/onUpload/simplifyGeoms/GeometrySimplificationProcessImpl.java +++ b/nunaliit2-couch-onUpload/src/main/java/ca/carleton/gcrc/couch/onUpload/simplifyGeoms/GeometrySimplificationProcessImpl.java @@ -38,6 +38,9 @@ public GeometrySimplificationReport simplifyGeometry(Geometry geometry) throws E if( geometry instanceof Point ){ // Do not simplify points + } + else if (geometry.isEmpty()) { + // Don't simplify what doesn't exist } else { Geometry lastGeometry = null; for(Double resolution : resolutions){ diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Geometry.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Geometry.java index f8e869195..8d48282af 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Geometry.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Geometry.java @@ -7,6 +7,8 @@ public interface Geometry { BoundingBox getBoundingBox(); void extendBoundingBox(BoundingBox boundingBox); + + boolean isEmpty(); /** * Unravels all the geometry collections and saves the basic diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/GeometryCollection.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/GeometryCollection.java index 052377f88..32fdecb72 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/GeometryCollection.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/GeometryCollection.java @@ -35,6 +35,12 @@ public void addGeometry(Geometry geometry){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("GEOMETRYCOLLECTION EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("GEOMETRYCOLLECTION("); @@ -68,4 +74,9 @@ public void accumulateBasicGeometries(Collection geometries) { geometry.accumulateBasicGeometries(geometries); } } + + @Override + public boolean isEmpty() { + return (getGeometries().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/LineString.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/LineString.java index 931bc4ef1..a998f7308 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/LineString.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/LineString.java @@ -29,6 +29,12 @@ public void addPoint(Point point){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("LINESTRING EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("LINESTRING("); @@ -69,4 +75,9 @@ public void extendBoundingBox(BoundingBox boundingBox) { public void accumulateBasicGeometries(Collection geometries) { geometries.add(this); } + + @Override + public boolean isEmpty() { + return (getPoints().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiLineString.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiLineString.java index 958daeeb5..f1ff2d0ac 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiLineString.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiLineString.java @@ -41,6 +41,12 @@ public void addLineString(LineString lineString){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("MULTILINESTRING EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("MULTILINESTRING("); @@ -94,4 +100,9 @@ public void accumulateBasicGeometries(Collection geometries) { lineString.accumulateBasicGeometries(geometries); } } + + @Override + public boolean isEmpty() { + return (getLineStrings().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPoint.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPoint.java index a877186f7..601f2a01a 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPoint.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPoint.java @@ -41,6 +41,12 @@ public void addPoint(Point point){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("MULTIPOINT EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("MULTIPOINT("); @@ -85,4 +91,9 @@ public void accumulateBasicGeometries(Collection geometries) { point.accumulateBasicGeometries(geometries); } } + + @Override + public boolean isEmpty() { + return (getPoints().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPolygon.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPolygon.java index 7fdf4a7ed..bf0cd9834 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPolygon.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/MultiPolygon.java @@ -41,6 +41,12 @@ public void addPolygon(Polygon polygon){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("MULTIPOLYGON EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("MULTIPOLYGON("); @@ -107,4 +113,9 @@ public void accumulateBasicGeometries(Collection geometries) { polygon.accumulateBasicGeometries(geometries); } } + + @Override + public boolean isEmpty() { + return (getPolygons().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Point.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Point.java index 27a8c43be..e80d4c41a 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Point.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Point.java @@ -69,6 +69,12 @@ public Double getZ(){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("POINT EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("POINT("); @@ -98,4 +104,9 @@ public void extendBoundingBox(BoundingBox boundingBox) { public void accumulateBasicGeometries(Collection geometries) { geometries.add(this); } + + @Override + public boolean isEmpty() { + return (getPositions().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Polygon.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Polygon.java index 22b9aaad1..e50e0ff5d 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Polygon.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/Polygon.java @@ -29,6 +29,12 @@ public void addLinearRing(LineString linearRing){ public String toString(){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + + if (isEmpty()) { + pw.print("POLYGON EMPTY"); + pw.flush(); + return sw.toString(); + } pw.print("POLYGON("); @@ -80,4 +86,9 @@ public void extendBoundingBox(BoundingBox boundingBox) { public void accumulateBasicGeometries(Collection geometries) { geometries.add(this); } + + @Override + public boolean isEmpty() { + return (getLinearRings().size() == 0); + } } diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktParser.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktParser.java index f56ff8aed..18e314cdd 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktParser.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktParser.java @@ -34,6 +34,11 @@ public Geometry parseWkt(Reader reader) throws Exception { BufferedReader bufReader = new BufferedReader(reader); return parseGeometry(bufReader); } + + private boolean isWKTEmpty(BufferedReader br) throws Exception { + String geomData = readIdentifier(br); + return geomData.equalsIgnoreCase("empty"); + } private Geometry parseGeometry(BufferedReader bufReader) throws Exception { @@ -41,7 +46,6 @@ private Geometry parseGeometry(BufferedReader bufReader) throws Exception { try { skipWhiteSpaces(bufReader); String identifier = readIdentifier(bufReader); - if( "point".equalsIgnoreCase(identifier) ) { geometry = parsePoint(bufReader); @@ -281,6 +285,11 @@ private List parsePositions(BufferedReader br) throws Exception { private Point parsePoint(BufferedReader br) throws Exception { skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return new Point(); + } + popLeftParen(br); List positions = parsePositions(br); @@ -299,6 +308,11 @@ private LineString parseLineString(BufferedReader br) throws Exception { LineString lineString = new LineString(); skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return lineString; + } + popLeftParen(br); // Accumulate points @@ -329,6 +343,11 @@ private Polygon parsePolygon(BufferedReader br) throws Exception { Polygon polygon = new Polygon(); skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return polygon; + } + popLeftParen(br); LineString ls = parseLineString(br); @@ -351,6 +370,11 @@ private MultiPoint parseMultiPoint(BufferedReader br) throws Exception { MultiPoint multiPoint = new MultiPoint(); skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return multiPoint; + } + popLeftParen(br); boolean done = false; @@ -386,6 +410,11 @@ private MultiLineString parseMultiLineString(BufferedReader br) throws Exception MultiLineString multiLineString = new MultiLineString(); skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return multiLineString; + } + popLeftParen(br); boolean done = false; @@ -412,6 +441,11 @@ private MultiPolygon parseMultiPolygon(BufferedReader br) throws Exception { MultiPolygon multiPolygon = new MultiPolygon(); skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return multiPolygon; + } + popLeftParen(br); boolean done = false; @@ -438,6 +472,11 @@ private GeometryCollection parseGeometryCollection(BufferedReader br) throws Exc GeometryCollection geometryCollection = new GeometryCollection(); skipWhiteSpaces(br); + + if (isWKTEmpty(br)) { + return geometryCollection; + } + popLeftParen(br); boolean done = false; diff --git a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktWriter.java b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktWriter.java index 899f6fa1a..7c401c578 100644 --- a/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktWriter.java +++ b/nunaliit2-geom/src/main/java/ca/carleton/gcrc/geom/wkt/WktWriter.java @@ -68,162 +68,133 @@ public void write(Geometry geometry, NumberFormat numFormat, PrintWriter pw) thr } private void writePoint(Point point, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("POINT("); - boolean firstPosition = true; - for(Number position : point.getPositions()){ - if( firstPosition ) { - firstPosition = false; - } else { - pw.write(" "); - } - - writeNumber(pw, numFormat, position); - } - pw.write(")"); - } - - private void writeMultiPoint(MultiPoint multiPoint, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("MULTIPOINT("); - boolean firstPoint = true; - for(Point point : multiPoint.getPoints()){ - if( firstPoint ) { - firstPoint = false; - } else { - pw.write(","); - } - - pw.write("("); - + if (point.isEmpty()) { + pw.write("POINT EMPTY"); + } else { + pw.write("POINT("); boolean firstPosition = true; - for(Number position : point.getPositions()){ - if( firstPosition ) { + for (Number position : point.getPositions()) { + if (firstPosition) { firstPosition = false; } else { pw.write(" "); } - - writeNumber(pw, numFormat, position); - } - - pw.write(")"); - } - pw.write(")"); - } - - private void writeLineString(LineString lineString, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("LINESTRING("); - boolean firstPoint = true; - for(Point point : lineString.getPoints()){ - if( firstPoint ) { - firstPoint = false; - } else { - pw.write(","); - } - boolean firstPosition = true; - for(Number position : point.getPositions()){ - if( firstPosition ) { - firstPosition = false; - } else { - pw.write(" "); - } - writeNumber(pw, numFormat, position); } + pw.write(")"); } - pw.write(")"); } - private void writeMultiLineString(MultiLineString multiLineString, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("MULTILINESTRING("); - boolean firstLineString = true; - for(LineString lineString : multiLineString.getLineStrings()){ - if( firstLineString ) { - firstLineString = false; - } else { - pw.write(","); - } - - pw.write("("); - + private void writeMultiPoint(MultiPoint multiPoint, NumberFormat numFormat, PrintWriter pw) throws Exception { + if (multiPoint.isEmpty()) { + pw.write("MULTIPOINT EMPTY"); + } else { + pw.write("MULTIPOINT("); boolean firstPoint = true; - for(Point point : lineString.getPoints()){ - if( firstPoint ) { + for (Point point : multiPoint.getPoints()) { + if (firstPoint) { firstPoint = false; } else { pw.write(","); } + pw.write("("); + boolean firstPosition = true; - for(Number position : point.getPositions()){ - if( firstPosition ) { + for (Number position : point.getPositions()) { + if (firstPosition) { firstPosition = false; } else { pw.write(" "); } - + writeNumber(pw, numFormat, position); } - } + pw.write(")"); + } pw.write(")"); } - pw.write(")"); } - private void writePolygon(Polygon polygon, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("POLYGON("); - boolean firstLinearRing = true; - for(LineString lineString : polygon.getLinearRings()){ - if( firstLinearRing ) { - firstLinearRing = false; - } else { - pw.write(","); - } - - pw.write("("); - + private void writeLineString(LineString lineString, NumberFormat numFormat, PrintWriter pw) throws Exception { + if (lineString.isEmpty()) { + pw.write("LINESTRING EMPTY"); + } else { + pw.write("LINESTRING("); boolean firstPoint = true; - for(Point point : lineString.getPoints()){ - if( firstPoint ) { + for (Point point : lineString.getPoints()) { + if (firstPoint) { firstPoint = false; } else { pw.write(","); } boolean firstPosition = true; - for(Number position : point.getPositions()){ - if( firstPosition ) { + for (Number position : point.getPositions()) { + if (firstPosition) { firstPosition = false; } else { pw.write(" "); } - + writeNumber(pw, numFormat, position); } } - pw.write(")"); } - pw.write(")"); } - private void writeMultiPolygon(MultiPolygon multiPolygon, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("MULTIPOLYGON("); - - boolean firstPolygon = true; - for(Polygon polygon : multiPolygon.getPolygons()){ - if( firstPolygon ) { - firstPolygon = false; - } else { - pw.write(","); - } + private void writeMultiLineString(MultiLineString multiLineString, NumberFormat numFormat, PrintWriter pw) throws Exception { + if (multiLineString.isEmpty()) { + pw.write("MULTILINESTRING EMPTY"); + } else { + pw.write("MULTILINESTRING("); + boolean firstLineString = true; + for (LineString lineString : multiLineString.getLineStrings()) { + if (firstLineString) { + firstLineString = false; + } else { + pw.write(","); + } - pw.write("("); - + pw.write("("); + + boolean firstPoint = true; + for (Point point : lineString.getPoints()) { + if (firstPoint) { + firstPoint = false; + } else { + pw.write(","); + } + + boolean firstPosition = true; + for (Number position : point.getPositions()) { + if (firstPosition) { + firstPosition = false; + } else { + pw.write(" "); + } + + writeNumber(pw, numFormat, position); + } + } + + pw.write(")"); + } + pw.write(")"); + } + } + + private void writePolygon(Polygon polygon, NumberFormat numFormat, PrintWriter pw) throws Exception { + if (polygon.isEmpty()) { + pw.write("POLYGON EMPTY"); + } else { + pw.write("POLYGON("); boolean firstLinearRing = true; - for(LineString lineString : polygon.getLinearRings()){ - if( firstLinearRing ) { + for (LineString lineString : polygon.getLinearRings()) { + if (firstLinearRing) { firstLinearRing = false; } else { pw.write(","); @@ -232,47 +203,104 @@ private void writeMultiPolygon(MultiPolygon multiPolygon, NumberFormat numFormat pw.write("("); boolean firstPoint = true; - for(Point point : lineString.getPoints()){ - if( firstPoint ) { + for (Point point : lineString.getPoints()) { + if (firstPoint) { firstPoint = false; } else { pw.write(","); } boolean firstPosition = true; - for(Number position : point.getPositions()){ - if( firstPosition ) { + for (Number position : point.getPositions()) { + if (firstPosition) { firstPosition = false; } else { pw.write(" "); } - + writeNumber(pw, numFormat, position); } } pw.write(")"); } - pw.write(")"); } + } + + private void writeMultiPolygon(MultiPolygon multiPolygon, NumberFormat numFormat, PrintWriter pw) throws Exception { + if (multiPolygon.isEmpty()) { + pw.write("MULTIPOLYGON EMPTY"); + } else { + pw.write("MULTIPOLYGON("); - pw.write(")"); + boolean firstPolygon = true; + for (Polygon polygon : multiPolygon.getPolygons()) { + if (firstPolygon) { + firstPolygon = false; + } else { + pw.write(","); + } + + pw.write("("); + + boolean firstLinearRing = true; + for (LineString lineString : polygon.getLinearRings()) { + if (firstLinearRing) { + firstLinearRing = false; + } else { + pw.write(","); + } + + pw.write("("); + + boolean firstPoint = true; + for (Point point : lineString.getPoints()) { + if (firstPoint) { + firstPoint = false; + } else { + pw.write(","); + } + + boolean firstPosition = true; + for (Number position : point.getPositions()) { + if (firstPosition) { + firstPosition = false; + } else { + pw.write(" "); + } + + writeNumber(pw, numFormat, position); + } + } + + pw.write(")"); + } + + pw.write(")"); + } + + pw.write(")"); + } } private void writeGeometryCollection(GeometryCollection geometryCollection, NumberFormat numFormat, PrintWriter pw) throws Exception { - pw.write("GEOMETRYCOLLECTION("); - boolean firstGeometry = true; - for(Geometry geometry : geometryCollection.getGeometries()){ - if( firstGeometry ) { - firstGeometry = false; - } else { - pw.write(","); + if (geometryCollection.isEmpty()) { + pw.write("GEOMETRYCOLLECTION EMPTY"); + } else { + pw.write("GEOMETRYCOLLECTION("); + boolean firstGeometry = true; + for (Geometry geometry : geometryCollection.getGeometries()) { + if (firstGeometry) { + firstGeometry = false; + } else { + pw.write(","); + } + + write(geometry, numFormat, pw); } - - write(geometry, numFormat, pw); + pw.write(")"); } - pw.write(")"); } /** diff --git a/nunaliit2-geom/src/test/java/ca/carleton/gcrc/geom/WktParserTest.java b/nunaliit2-geom/src/test/java/ca/carleton/gcrc/geom/WktParserTest.java index 03b0ae580..4999d2f58 100644 --- a/nunaliit2-geom/src/test/java/ca/carleton/gcrc/geom/WktParserTest.java +++ b/nunaliit2-geom/src/test/java/ca/carleton/gcrc/geom/WktParserTest.java @@ -121,4 +121,50 @@ public void testGeometryCollection() throws Exception { fail("Expected two geometries"); } } + + public void testEmptyWKT() throws Exception { + Geometry geomPoint = (new WktParser()).parseWkt("POINT EMPTY"); + Geometry geomLineString = (new WktParser()).parseWkt("LINESTRING EMPTY"); + Geometry geomPolygon = (new WktParser()).parseWkt("POLYGON EMPTY"); + Geometry geomMultiPoint = (new WktParser()).parseWkt("MULTIPOINT EMPTY"); + Geometry geomMultiLineString = (new WktParser()).parseWkt("MULTILINESTRING EMPTY"); + Geometry geomMultiPolygon = (new WktParser()).parseWkt("MULTIPOLYGON EMPTY"); + Geometry geomGeometryCollection = (new WktParser()).parseWkt("GEOMETRYCOLLECTION EMPTY"); + + if (false == (geomPoint instanceof Point)) fail("Expected an instance of Point"); + if (false == (geomLineString instanceof LineString)) fail("Expected an instance of LineString"); + if (false == (geomPolygon instanceof Polygon)) fail("Expected an instance of Polygon"); + if (false == (geomMultiPoint instanceof MultiPoint)) fail("Expected an instance of MultiPoint"); + if (false == (geomMultiLineString instanceof MultiLineString)) fail("Expected an instance of MultiLineString"); + if (false == (geomMultiPolygon instanceof MultiPolygon)) fail("Expected an instance of MultiPolygon"); + if (false == (geomGeometryCollection instanceof GeometryCollection)) fail("Expected an instance of GeometryCollection"); + + Point point = (Point) geomPoint; + if (point.getPositions().size() != 0) fail("Expected no positions"); + if (!point.toString().equals("POINT EMPTY")) fail("Unexpected WKT string for empty POINT"); + + LineString ls = (LineString) geomLineString; + if (ls.getPoints().size() != 0) fail("Expected no points"); + if (!ls.toString().equals("LINESTRING EMPTY")) fail("Unexpected WKT string for empty LINESTRING"); + + Polygon polygon = (Polygon) geomPolygon; + if (polygon.getLinearRings().size() != 0) fail("Expected no linear rings"); + if (!polygon.toString().equals("POLYGON EMPTY")) fail("Unexpected WKT string for empty POLYGON"); + + MultiPoint multipoint = (MultiPoint) geomMultiPoint; + if (multipoint.getPoints().size() != 0) fail("Expected no points"); + if (!multipoint.toString().equals("MULTIPOINT EMPTY")) fail("Unexpected WKT string for empty MULTIPOINT"); + + MultiLineString multiLS = (MultiLineString) geomMultiLineString; + if (multiLS.getLineStrings().size() != 0) fail("Expected no linestrings"); + if (!multiLS.toString().equals("MULTILINESTRING EMPTY")) fail("Unexpected WKT string for empty MULTILINESTRING"); + + MultiPolygon multiPolygon = (MultiPolygon) geomMultiPolygon; + if (multiPolygon.getPolygons().size() != 0) fail("Expected no polygons"); + if (!multiPolygon.toString().equals("MULTIPOLYGON EMPTY")) fail("Unexpected WKT string for empty MULTIPOLYGON"); + + GeometryCollection gCollection = (GeometryCollection) geomGeometryCollection; + if (gCollection.getGeometries().size() != 0) fail("Expected no geometries"); + if (!gCollection.toString().equals("GEOMETRYCOLLECTION EMPTY")) fail("Unexpected WKT string for empty GEOMETRYCOLLECTION"); + } } diff --git a/nunaliit2-js/src/main/js/nunaliit2/n2.mapAndControls.js b/nunaliit2-js/src/main/js/nunaliit2/n2.mapAndControls.js index 2771c8f16..96f880410 100644 --- a/nunaliit2-js/src/main/js/nunaliit2/n2.mapAndControls.js +++ b/nunaliit2-js/src/main/js/nunaliit2/n2.mapAndControls.js @@ -5707,7 +5707,7 @@ var MapAndControls = $n2.Class('MapAndControls',{ } else if( 'find' === type ) { var doc = m.doc; - if( doc && doc.nunaliit_geom ){ + if( doc && doc.nunaliit_geom && doc.nunaliit_geom.bbox ){ var x = (doc.nunaliit_geom.bbox[0] + doc.nunaliit_geom.bbox[2]) / 2; var y = (doc.nunaliit_geom.bbox[1] + doc.nunaliit_geom.bbox[3]) / 2; this._centerMapOnXY(x, y, 'EPSG:4326');