mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-26 08:00:41 +00:00
Update
This commit is contained in:
@@ -2,6 +2,9 @@ package com.avaje.ebean.postgis;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.plugin.ExtraTypeFactory;
|
||||
import com.avaje.ebean.postgis.latte.ScalarTypeGeoLatteLineString;
|
||||
import com.avaje.ebean.postgis.latte.ScalarTypeGeoLatteMultiLineString;
|
||||
import com.avaje.ebean.postgis.latte.ScalarTypeGeoLatteMultiPoint;
|
||||
import com.avaje.ebean.postgis.latte.ScalarTypeGeoLatteMultiPolygon;
|
||||
import com.avaje.ebean.postgis.latte.ScalarTypeGeoLattePoint;
|
||||
import com.avaje.ebean.postgis.latte.ScalarTypeGeoLattePolygon;
|
||||
@@ -19,12 +22,18 @@ public class RegisterFactory implements ExtraTypeFactory {
|
||||
List<ScalarType<?>> list = new ArrayList<ScalarType<?>>();
|
||||
list.add(new ScalarTypePgisPoint());
|
||||
list.add(new ScalarTypePgisPolygon());
|
||||
list.add(new ScalarTypePgisLineString());
|
||||
list.add(new ScalarTypePgisMultiPolygon());
|
||||
list.add(new ScalarTypePgisMultiPoint());
|
||||
list.add(new ScalarTypePgisMultiLineString());
|
||||
|
||||
if (serverConfig.getClassLoadConfig().isPresent("org.geolatte.geom.Geometry")) {
|
||||
list.add(new ScalarTypeGeoLattePoint());
|
||||
list.add(new ScalarTypeGeoLattePolygon());
|
||||
list.add(new ScalarTypeGeoLatteLineString());
|
||||
list.add(new ScalarTypeGeoLatteMultiPolygon());
|
||||
list.add(new ScalarTypeGeoLatteMultiPoint());
|
||||
list.add(new ScalarTypeGeoLatteMultiLineString());
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.avaje.ebean.postgis;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import org.postgis.LineString;
|
||||
import org.postgis.Point;
|
||||
|
||||
public class ScalarTypePgisLineString extends ScalarTypePgisBase<LineString> {
|
||||
|
||||
public ScalarTypePgisLineString() {
|
||||
super(ExtraDbTypes.LINESTRING, LineString.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.avaje.ebean.postgis;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import org.postgis.LineString;
|
||||
import org.postgis.MultiLineString;
|
||||
|
||||
public class ScalarTypePgisMultiLineString extends ScalarTypePgisBase<MultiLineString> {
|
||||
|
||||
public ScalarTypePgisMultiLineString() {
|
||||
super(ExtraDbTypes.MULTILINESTRING, MultiLineString.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.avaje.ebean.postgis;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import org.postgis.MultiLineString;
|
||||
import org.postgis.MultiPoint;
|
||||
|
||||
public class ScalarTypePgisMultiPoint extends ScalarTypePgisBase<MultiPoint> {
|
||||
|
||||
public ScalarTypePgisMultiPoint() {
|
||||
super(ExtraDbTypes.MULTIPOINT, MultiPoint.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.postgis.MultiPolygon;
|
||||
public class ScalarTypePgisMultiPolygon extends ScalarTypePgisBase<MultiPolygon> {
|
||||
|
||||
public ScalarTypePgisMultiPolygon() {
|
||||
super(ExtraDbTypes.POLYGON, MultiPolygon.class);
|
||||
super(ExtraDbTypes.MULTIPOLYGON, MultiPolygon.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.avaje.ebean.postgis.latte;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
|
||||
public class ScalarTypeGeoLatteLineString extends ScalarTypeGeoLatteBase<LineString> {
|
||||
|
||||
public ScalarTypeGeoLatteLineString() {
|
||||
super(ExtraDbTypes.LINESTRING, LineString.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.avaje.ebean.postgis.latte;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
import org.geolatte.geom.MultiPolygon;
|
||||
|
||||
public class ScalarTypeGeoLatteMultiLineString extends ScalarTypeGeoLatteBase<MultiLineString> {
|
||||
|
||||
public ScalarTypeGeoLatteMultiLineString() {
|
||||
super(ExtraDbTypes.MULTILINESTRING, MultiLineString.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.avaje.ebean.postgis.latte;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import org.geolatte.geom.MultiPoint;
|
||||
|
||||
public class ScalarTypeGeoLatteMultiPoint extends ScalarTypeGeoLatteBase<MultiPoint> {
|
||||
|
||||
public ScalarTypeGeoLatteMultiPoint() {
|
||||
super(ExtraDbTypes.MULTIPOINT, MultiPoint.class);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.example.domain;
|
||||
|
||||
|
||||
import org.postgis.LineString;
|
||||
import org.postgis.MultiLineString;
|
||||
import org.postgis.MultiPoint;
|
||||
import org.postgis.MultiPolygon;
|
||||
import org.postgis.Point;
|
||||
import org.postgis.Polygon;
|
||||
@@ -18,6 +20,12 @@ public class MyBean extends BaseEntity {
|
||||
|
||||
Polygon poly;
|
||||
|
||||
LineString lineString;
|
||||
|
||||
MultiLineString multiLineString;
|
||||
|
||||
MultiPoint multiPoint;
|
||||
|
||||
MultiPolygon mpoly;
|
||||
|
||||
public String getName() {
|
||||
@@ -44,6 +52,30 @@ public class MyBean extends BaseEntity {
|
||||
this.poly = poly;
|
||||
}
|
||||
|
||||
public LineString getLineString() {
|
||||
return lineString;
|
||||
}
|
||||
|
||||
public void setLineString(LineString lineString) {
|
||||
this.lineString = lineString;
|
||||
}
|
||||
|
||||
public MultiLineString getMultiLineString() {
|
||||
return multiLineString;
|
||||
}
|
||||
|
||||
public void setMultiLineString(MultiLineString multiLineString) {
|
||||
this.multiLineString = multiLineString;
|
||||
}
|
||||
|
||||
public MultiPoint getMultiPoint() {
|
||||
return multiPoint;
|
||||
}
|
||||
|
||||
public void setMultiPoint(MultiPoint multiPoint) {
|
||||
this.multiPoint = multiPoint;
|
||||
}
|
||||
|
||||
public MultiPolygon getMpoly() {
|
||||
return mpoly;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.example.domain;
|
||||
|
||||
|
||||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
import org.geolatte.geom.MultiPoint;
|
||||
import org.geolatte.geom.MultiPolygon;
|
||||
import org.geolatte.geom.Point;
|
||||
import org.geolatte.geom.Polygon;
|
||||
@@ -18,6 +21,12 @@ public class OtherBeanGeoLatte extends BaseEntity {
|
||||
|
||||
Polygon poly;
|
||||
|
||||
LineString lineString;
|
||||
|
||||
MultiLineString multiLineString;
|
||||
|
||||
MultiPoint multiPoint;
|
||||
|
||||
MultiPolygon mpoly;
|
||||
|
||||
public String getName() {
|
||||
@@ -51,4 +60,28 @@ public class OtherBeanGeoLatte extends BaseEntity {
|
||||
public void setMpoly(MultiPolygon mpoly) {
|
||||
this.mpoly = mpoly;
|
||||
}
|
||||
|
||||
public LineString getLineString() {
|
||||
return lineString;
|
||||
}
|
||||
|
||||
public void setLineString(LineString lineString) {
|
||||
this.lineString = lineString;
|
||||
}
|
||||
|
||||
public MultiLineString getMultiLineString() {
|
||||
return multiLineString;
|
||||
}
|
||||
|
||||
public void setMultiLineString(MultiLineString multiLineString) {
|
||||
this.multiLineString = multiLineString;
|
||||
}
|
||||
|
||||
public MultiPoint getMultiPoint() {
|
||||
return multiPoint;
|
||||
}
|
||||
|
||||
public void setMultiPoint(MultiPoint multiPoint) {
|
||||
this.multiPoint = multiPoint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package org.example.domain;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import org.postgis.LineString;
|
||||
import org.postgis.MultiLineString;
|
||||
import org.postgis.MultiPoint;
|
||||
import org.postgis.MultiPolygon;
|
||||
import org.postgis.Point;
|
||||
import org.postgis.Polygon;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -10,6 +15,10 @@ import java.util.List;
|
||||
|
||||
public class TestInsertQuery {
|
||||
|
||||
/**
|
||||
* Not automated this test yet.
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void insert() throws SQLException {
|
||||
|
||||
@@ -29,11 +38,19 @@ public class TestInsertQuery {
|
||||
|
||||
Point point = new Point("SRID=4674;POINT(2.8 1.7)");
|
||||
Polygon poly = new Polygon("SRID=4674;POLYGON((2 2, 2 -2, -2 -2, -2 2, 2 2))");
|
||||
LineString lineString = new LineString("SRID=4674;LINESTRING(0 0, 1 2)");
|
||||
MultiLineString multiLineString = new MultiLineString("SRID=4674;MULTILINESTRING((0 0, 1 2), (1 2, 3 -1))");
|
||||
MultiPoint multiPoint = new MultiPoint("SRID=4674;MULTIPOINT((2 3), (7 8))");
|
||||
MultiPolygon mpoly = new MultiPolygon("SRID=4674;MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 3, 1 1)))");
|
||||
|
||||
MyBean p = new MyBean();
|
||||
p.setName("me at "+System.currentTimeMillis());
|
||||
p.setPoint(point);
|
||||
p.setPoly(poly);
|
||||
p.setLineString(lineString);
|
||||
p.setMultiLineString(multiLineString);
|
||||
p.setMultiPoint(multiPoint);
|
||||
p.setMpoly(mpoly);
|
||||
|
||||
Ebean.save(p);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package org.example.domain;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import org.geolatte.geom.Point;
|
||||
import org.geolatte.geom.Polygon;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
import org.geolatte.geom.MultiPoint;
|
||||
import org.geolatte.geom.MultiPolygon;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.sql.SQLException;
|
||||
@@ -11,6 +16,10 @@ import java.util.List;
|
||||
|
||||
public class TestOtherInsertQuery {
|
||||
|
||||
/**
|
||||
* Not automated this test yet.
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void insert() throws SQLException {
|
||||
|
||||
@@ -31,10 +40,19 @@ public class TestOtherInsertQuery {
|
||||
Point point = (Point) Wkt.fromWkt("SRID=4674;POINT (12 23)");
|
||||
Polygon poly = (Polygon) Wkt.fromWkt("SRID=4674;POLYGON((2 2, 2 -2, -2 -2, -2 2, 2 2))");
|
||||
|
||||
LineString lineString = (LineString)Wkt.fromWkt("SRID=4674;LINESTRING(0 0, 1 2)");
|
||||
MultiLineString multiLineString = (MultiLineString)Wkt.fromWkt("SRID=4674;MULTILINESTRING((0 0, 1 2), (1 2, 3 -1))");
|
||||
MultiPoint multiPoint = (MultiPoint)Wkt.fromWkt("SRID=4674;MULTIPOINT(10 40, 40 30, 20 20, 30 10)");
|
||||
MultiPolygon mpoly = (MultiPolygon)Wkt.fromWkt("SRID=4674;MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 3, 1 1)))");
|
||||
|
||||
OtherBeanGeoLatte p = new OtherBeanGeoLatte();
|
||||
p.setName("geolatte at "+System.currentTimeMillis());
|
||||
p.setPoint(point);
|
||||
p.setPoly(poly);
|
||||
p.setLineString(lineString);
|
||||
p.setMpoly(mpoly);
|
||||
p.setMultiPoint(multiPoint);
|
||||
p.setMultiLineString(multiLineString);
|
||||
|
||||
Ebean.save(p);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
## when running tests
|
||||
|
||||
ebean.ddl.generate=true
|
||||
ebean.ddl.run=true
|
||||
#ebean.ddl.run=true
|
||||
#ebean.ddl.createOnly=true
|
||||
|
||||
ebean.geometrySRID=4674
|
||||
|
||||
Reference in New Issue
Block a user