diff --git a/gears/src/main/java/org/hortonmachine/gears/io/dbs/DbsHelper.java b/gears/src/main/java/org/hortonmachine/gears/io/dbs/DbsHelper.java index 5466fa9e9..05e153ec8 100644 --- a/gears/src/main/java/org/hortonmachine/gears/io/dbs/DbsHelper.java +++ b/gears/src/main/java/org/hortonmachine/gears/io/dbs/DbsHelper.java @@ -74,7 +74,11 @@ public static DefaultFeatureCollection runRawSqlToFeatureCollection( String name tableName = afterFrom.substring(0, nextAp); } else { int nextSpace = afterFrom.indexOf(' '); - tableName = afterFrom.substring(0, nextSpace); + if (nextSpace == -1) { + tableName = afterFrom; + }else { + tableName = afterFrom.substring(0, nextSpace); + } } if (tableName == null) { diff --git a/gears/src/test/java/org/hortonmachine/gears/TestTransformationUtils.java b/gears/src/test/java/org/hortonmachine/gears/TestTransformationUtils.java index ae083c932..7661dcc5a 100644 --- a/gears/src/test/java/org/hortonmachine/gears/TestTransformationUtils.java +++ b/gears/src/test/java/org/hortonmachine/gears/TestTransformationUtils.java @@ -35,6 +35,23 @@ public void testTransformationUtils() throws Exception { assertEquals(4000, (int) transformed.getY()); } + public void testTransformationUtilsTmp() throws Exception { + Envelope env = new Envelope(11.337890625, 11.42578125, 44.465151013519616, 44.5278427984555); + Rectangle rect = new Rectangle(0, 0, 512, 512); + + AffineTransformation worldToPixel = TransformationUtils.getWorldToRectangle(env, rect); + + Coordinate srcPt = new Coordinate(150.0, 3000.0); + Coordinate transformed = worldToPixel.transform(srcPt, new Coordinate()); + assertEquals(50, (int) transformed.x); + assertEquals(2000, (int) transformed.y); + + srcPt = new Coordinate(100.0, 1000.0); + transformed = worldToPixel.transform(srcPt, new Coordinate()); + assertEquals(0, (int) transformed.x); + assertEquals(4000, (int) transformed.y); + } + public void testTransformationUtils2() throws Exception { Envelope env = new Envelope(100, 200, 1000, 5000); Rectangle rect = new Rectangle(0, 0, 100, 4000);