Skip to content

Commit

Permalink
added function to trianguate CityGML boundary surfaces and inserting in
Browse files Browse the repository at this point in the history
PostGIS
  • Loading branch information
hgryoo committed Jul 17, 2018
1 parent 3ce7f5a commit 5b82978
Show file tree
Hide file tree
Showing 10 changed files with 1,177,918 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.geotools.feature.type.ComplexTypeImpl;
import org.geotools.feature.type.ProfileImpl;
import org.geotools.feature.type.SchemaImpl;
import org.geotools.gml3.iso.GML;
import org.geotools.gml3.iso.smil.SMIL20LANGSchema;
import org.geotools.xlink.XLINKSchema;
import org.geotools.xs.XSSchema;
Expand All @@ -21,8 +20,14 @@
import org.opengis.feature.type.Name;
import org.opengis.feature.type.PropertyDescriptor;
import org.opengis.filter.Filter;
import org.opengis.geometry.Geometry;
import org.opengis.geometry.aggregate.MultiCurve;
import org.opengis.geometry.aggregate.MultiPoint;
import org.opengis.geometry.aggregate.MultiPrimitive;
import org.opengis.geometry.aggregate.MultiSurface;
import org.opengis.geometry.primitive.Curve;
import org.opengis.geometry.primitive.Point;
import org.opengis.geometry.primitive.Ring;
import org.opengis.geometry.primitive.Solid;
import org.opengis.geometry.primitive.Surface;

Expand Down Expand Up @@ -808,7 +813,7 @@ XSSchema.ID_TYPE, new NameImpl("http://www.opengis.net/gml","id"), 0, 1, true, n
private static AttributeType build_ABSTRACTGEOMETRYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","AbstractGeometryType"), com.vividsolutions.jts.geom.Geometry.class, false,
new NameImpl("http://www.opengis.net/gml","AbstractGeometryType"), Geometry.class, false,
true, Collections.<Filter>emptyList(), ABSTRACTGMLTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -999,7 +1004,7 @@ XSSchema.DECIMAL_TYPE, new NameImpl("http://www.opengis.net/gml","Z"), 0, 1, fal
private static AttributeType build_POINTTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","PointType"), com.vividsolutions.jts.geom.Point.class, false,
new NameImpl("http://www.opengis.net/gml","PointType"), Point.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTGEOMETRICPRIMITIVETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -1041,7 +1046,7 @@ private static AttributeType build_POINTTYPE_TYPE() {
private static AttributeType build_POINTPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","PointPropertyType"), com.vividsolutions.jts.geom.Point.class, false,
new NameImpl("http://www.opengis.net/gml","PointPropertyType"), Point.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -4068,7 +4073,7 @@ XSSchema.STRING_TYPE, new NameImpl("http://www.w3.org/1999/xlink","type"), 0, 1,
private static AttributeType build_LINEARRINGTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","LinearRingType"), com.vividsolutions.jts.geom.LinearRing.class, false,
new NameImpl("http://www.opengis.net/gml","LinearRingType"), Curve.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTRINGTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -4098,7 +4103,7 @@ private static AttributeType build_LINEARRINGTYPE_TYPE() {
private static AttributeType build_LINEARRINGPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","LinearRingPropertyType"), com.vividsolutions.jts.geom.LinearRing.class, false,
new NameImpl("http://www.opengis.net/gml","LinearRingPropertyType"), Ring.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -6304,7 +6309,7 @@ POINTTYPE_TYPE, new NameImpl("http://www.opengis.net/gml","Point"), 0, 214748364
private static AttributeType build_MULTIPOINTTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiPointType"), com.vividsolutions.jts.geom.MultiPoint.class, false,
new NameImpl("http://www.opengis.net/gml","MultiPointType"), MultiPoint.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTGEOMETRICAGGREGATETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -6340,7 +6345,7 @@ private static AttributeType build_MULTIPOINTTYPE_TYPE() {
private static AttributeType build_MULTIPOINTPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiPointPropertyType"), com.vividsolutions.jts.geom.MultiPoint.class, false,
new NameImpl("http://www.opengis.net/gml","MultiPointPropertyType"), MultiPoint.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -8853,7 +8858,7 @@ XSSchema.STRING_TYPE, new NameImpl("http://www.w3.org/1999/xlink","type"), 0, 1,
private static AttributeType build_SURFACEPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","SurfacePropertyType"), com.vividsolutions.jts.geom.Polygon.class, false,
new NameImpl("http://www.opengis.net/gml","SurfacePropertyType"), Surface.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -8928,7 +8933,7 @@ ABSTRACTSURFACETYPE_TYPE, new NameImpl("http://www.opengis.net/gml","_Surface"),
private static AttributeType build_MULTISURFACETYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiSurfaceType"), com.vividsolutions.jts.geom.MultiPolygon.class, false,
new NameImpl("http://www.opengis.net/gml","MultiSurfaceType"), MultiSurface.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTGEOMETRICAGGREGATETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -9491,7 +9496,7 @@ private static ComplexType build_ABSTRACTCURVETYPE_TYPE() {
private static AttributeType build_LINESTRINGTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","LineStringType"), com.vividsolutions.jts.geom.LineString.class, false,
new NameImpl("http://www.opengis.net/gml","LineStringType"), Curve.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTCURVETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -9534,7 +9539,7 @@ private static AttributeType build_LINESTRINGTYPE_TYPE() {
private static AttributeType build_LINESTRINGPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","LineStringPropertyType"), com.vividsolutions.jts.geom.LineString.class, false,
new NameImpl("http://www.opengis.net/gml","LineStringPropertyType"), Curve.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -9568,7 +9573,7 @@ private static AttributeType build_LINESTRINGPROPERTYTYPE_TYPE() {
private static AttributeType build_MULTILINESTRINGTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiLineStringType"), com.vividsolutions.jts.geom.MultiLineString.class, false,
new NameImpl("http://www.opengis.net/gml","MultiLineStringType"), MultiCurve.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTGEOMETRICAGGREGATETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -9605,7 +9610,7 @@ private static AttributeType build_MULTILINESTRINGTYPE_TYPE() {
private static AttributeType build_MULTILINESTRINGPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiLineStringPropertyType"), com.vividsolutions.jts.geom.MultiLineString.class, false,
new NameImpl("http://www.opengis.net/gml","MultiLineStringPropertyType"), MultiCurve.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -10244,7 +10249,7 @@ XSSchema.INTEGER_TYPE, new NameImpl("http://www.opengis.net/gml","Count"), 1, 1,
private static AttributeType build_MULTISURFACEPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiSurfacePropertyType"), com.vividsolutions.jts.geom.MultiPolygon.class, false,
new NameImpl("http://www.opengis.net/gml","MultiSurfacePropertyType"), MultiSurface.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -11605,7 +11610,7 @@ ABSTRACTSURFACEPATCHTYPE_TYPE, new NameImpl("http://www.opengis.net/gml","_Surfa
private static AttributeType build_SURFACETYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","SurfaceType"), com.vividsolutions.jts.geom.Polygon.class, false,
new NameImpl("http://www.opengis.net/gml","SurfaceType"), Surface.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTSURFACETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -15514,7 +15519,7 @@ private static AttributeType build_INTEGERORNULL_TYPE() {
private static AttributeType build_MULTIGEOMETRYPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiGeometryPropertyType"), com.vividsolutions.jts.geom.GeometryCollection.class, false,
new NameImpl("http://www.opengis.net/gml","MultiGeometryPropertyType"), MultiPrimitive.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -22422,7 +22427,7 @@ private static ComplexType build_TIMETYPE_TYPE() {
private static AttributeType build_POLYGONPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","PolygonPropertyType"), com.vividsolutions.jts.geom.Polygon.class, false,
new NameImpl("http://www.opengis.net/gml","PolygonPropertyType"), Surface.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -22456,7 +22461,7 @@ private static AttributeType build_POLYGONPROPERTYTYPE_TYPE() {
private static AttributeType build_MULTIPOLYGONTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiPolygonType"), com.vividsolutions.jts.geom.MultiPolygon.class, false,
new NameImpl("http://www.opengis.net/gml","MultiPolygonType"), MultiSurface.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTGEOMETRICAGGREGATETYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -22494,7 +22499,7 @@ private static AttributeType build_MULTIPOLYGONTYPE_TYPE() {
private static AttributeType build_MULTIPOLYGONPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiPolygonPropertyType"), com.vividsolutions.jts.geom.MultiPolygon.class, false,
new NameImpl("http://www.opengis.net/gml","MultiPolygonPropertyType"), MultiSurface.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -23430,7 +23435,7 @@ XSSchema.STRING_TYPE, new NameImpl("http://www.w3.org/1999/xlink","type"), 0, 1,
private static AttributeType build_GEOMETRYPROPERTYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","GeometryPropertyType"), com.vividsolutions.jts.geom.Geometry.class, false,
new NameImpl("http://www.opengis.net/gml","GeometryPropertyType"), Geometry.class, false,
false, Collections.<Filter>emptyList(), XSSchema.ANYTYPE_TYPE, null
);
return builtType;
Expand Down Expand Up @@ -23506,7 +23511,7 @@ ABSTRACTGEOMETRYTYPE_TYPE, new NameImpl("http://www.opengis.net/gml","_Geometry"
private static AttributeType build_MULTIGEOMETRYTYPE_TYPE() {
AttributeType builtType;
builtType = new AttributeTypeImpl(
new NameImpl("http://www.opengis.net/gml","MultiGeometryType"), com.vividsolutions.jts.geom.GeometryCollection.class, false,
new NameImpl("http://www.opengis.net/gml","MultiGeometryType"), MultiPrimitive.class, false,
false, Collections.<Filter>emptyList(), ABSTRACTGEOMETRICAGGREGATETYPE_TYPE, null
);
return builtType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@
*/
package org.geotools.gml3.iso.bindings;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.xml.namespace.QName;

import org.geotools.gml3.iso.GML;
import org.geotools.gml3.iso.bindings.MultiSurfaceTypeBinding;
import org.geotools.xml.AbstractComplexBinding;
import org.geotools.xml.ElementInstance;
import org.geotools.xml.Node;
import org.opengis.geometry.ISOGeometryBuilder;
import org.opengis.geometry.aggregate.MultiPoint;
import org.opengis.geometry.aggregate.MultiSurface;

import com.vividsolutions.jts.geom.Polygon;
import org.opengis.geometry.primitive.OrientableSurface;
import org.opengis.geometry.primitive.Point;
import org.opengis.geometry.primitive.Surface;


/**
Expand Down Expand Up @@ -96,27 +99,27 @@ public Class getType() {
*/
public Object parse(ElementInstance instance, Node node, Object value)
throws Exception {
List polys = node.getChildValues(Polygon.class);
List polys = node.getChildValues(Surface.class);
Set<Surface> set = new HashSet<Surface>(polys);
return gBuilder.createMultiSurface(set);

//return gFactory.createMultiPolygon((Polygon[]) polys.toArray(new Polygon[polys.size()]));
return null;
}

public Object getProperty(Object object, QName name)
throws Exception {
if (GML.polygonMember.equals(name)) {
/* MultiPolygon multiPolygon = (MultiPolygon) object;
Polygon[] members = new Polygon[multiPolygon.getNumGeometries()];
for (int i = 0; i < members.length; i++) {
members[i] = (Polygon) multiPolygon.getGeometryN(i);
}
GML3EncodingUtils.setChildIDs(multiPolygon);*/

return null;
MultiSurface multiSurface = (MultiSurface) object;
Surface[] members = new Surface[multiSurface.getElements().size()];
int i = 0;
for (OrientableSurface s : multiSurface.getElements()) {
members[i++] = (Surface) s;
}
GML3EncodingUtils.setChildIDs(multiSurface);

return members;
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public String multiCurveToString(MultiCurve mc) {
}

public String multiSurfaceToString(MultiSurface ms) {
return "MultiSurface(" + this.multiSurfaceCoordToString(ms) + ")";
return "MultiPolygon(" + this.multiSurfaceCoordToString(ms) + ")";
}

public String multiSolidToString(MultiSolidImpl ms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ public void encodeGeometryValue(Geometry value, int dimension, int srid, StringB

GeometryToPostGISWKTString writer = new GeometryToPostGISWKTString(false);
String wkt = writer.getString(value);
sql.append("ST_GeomFromEWKT('" + wkt + ")'");
sql.append("ST_GeomFromEWKT('" + "SRID=" + srid + ";" + wkt + "')");


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ protected void visitLiteralGeometry(Literal expression) throws IOException {
} else {
out.write("'SRID=" + currentSRID + ";");
}
out.write(writer.getString(geom));//geom.toText());
out.write(writer.getString(geom));
//geom.toText());

/*
if(geom.getCoordinateReferenceSystem() == null && currentGeometry != null) {
Expand Down
21 changes: 21 additions & 0 deletions tutorial/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
<version>2.7.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.osgeo/proj4j -->
<dependency>
<groupId>org.osgeo</groupId>
<artifactId>proj4j</artifactId>
<version>0.1.0</version>
</dependency>

<!-- Provides GUI components -->
<dependency>
<groupId>org.geotools</groupId>
Expand All @@ -71,6 +78,20 @@
<artifactId>gt-cql</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>earcut4j</groupId>
<artifactId>earcut4j</artifactId>
<version>2.1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/lib/earcut4j-2.1.1.jar</systemPath>
</dependency>

<dependency>
<groupId>edu.pnu.stemlab</groupId>
<artifactId>sfcgal4j-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!--<dependency>
<groupId>org.geotools.jdbc</groupId>
<artifactId>gt-jdbc-oracle-iso</artifactId>
Expand Down
Loading

0 comments on commit 5b82978

Please sign in to comment.