use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class TriangulationFunctions method delaunayTrianglesWithTolerance.
public static Polygonal delaunayTrianglesWithTolerance(final Geometry geom, final double tolerance) {
GeometryFactory geometryFactory = geom.getGeometryFactory();
geometryFactory = geometryFactory.convertScales(tolerance, tolerance, tolerance);
final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
builder.insertVertices(geom);
final Polygonal triangles = builder.getTrianglesPolygonal();
return triangles;
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class OracleDdlWriter method writeAddGeometryColumn.
public void writeAddGeometryColumn(final RecordDefinition recordDefinition) {
final PrintWriter out = getOut();
final String typePath = recordDefinition.getPath();
String schemaName = JdbcUtils.getSchemaName(typePath);
if (schemaName.length() == 0) {
schemaName = "public";
}
final String tableName = PathUtil.getName(typePath);
final FieldDefinition geometryField = recordDefinition.getGeometryField();
if (geometryField != null) {
final GeometryFactory geometryFactory = geometryField.getProperty(FieldProperties.GEOMETRY_FACTORY);
final String name = geometryField.getName();
String geometryType = "GEOMETRY";
final DataType dataType = geometryField.getDataType();
if (dataType == DataTypes.POINT) {
geometryType = "POINT";
} else if (dataType == DataTypes.LINE_STRING) {
geometryType = "LINESTRING";
} else if (dataType == DataTypes.POLYGON) {
geometryType = "POLYGON";
} else if (dataType == DataTypes.MULTI_POINT) {
geometryType = "MULTIPOINT";
} else if (dataType == DataTypes.MULTI_LINE_STRING) {
geometryType = "MULTILINESTRING";
} else if (dataType == DataTypes.MULTI_POLYGON) {
geometryType = "MULTIPOLYGON";
}
out.print("select addgeometrycolumn('");
out.print(schemaName.toLowerCase());
out.print("', '");
out.print(tableName.toLowerCase());
out.print("','");
out.print(name.toLowerCase());
out.print("',");
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
out.print(coordinateSystem.getCoordinateSystemId());
out.print(",'");
out.print(geometryType);
out.print("', ");
out.print(geometryFactory.getAxisCount());
out.println(");");
}
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class OracleDdlWriter method writeGeometryRecordDefinition.
@Override
public void writeGeometryRecordDefinition(final RecordDefinition recordDefinition) {
final PrintWriter out = getOut();
final String typePath = recordDefinition.getPath();
final String schemaName = JdbcUtils.getSchemaName(typePath);
final String tableName = PathUtil.getName(typePath);
final FieldDefinition geometryField = recordDefinition.getGeometryField();
if (geometryField != null) {
final GeometryFactory geometryFactory = geometryField.getProperty(FieldProperties.GEOMETRY_FACTORY);
final String name = geometryField.getName();
final int axisCount = geometryFactory.getAxisCount();
final DataType dataType = geometryField.getDataType();
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
final int srid = coordinateSystem.getCoordinateSystemId();
out.print("INSERT INTO USER_SDO_GEOM_METADATA(TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES('");
out.print(tableName.toUpperCase());
out.print("','");
out.print(name.toUpperCase());
// TODO get from geometry factory
out.print("',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 263000, 1876000, 0.001),MDSYS.SDO_DIM_ELEMENT('Y', 356000, 1738000, 0.001)");
if (axisCount > 2) {
out.print(",MDSYS.SDO_DIM_ELEMENT('Z',-2500, 5000, 0.001)");
}
out.print("),");
out.println("3005);");
final int geometryType = OracleSdoGeometryFieldAdder.getGeometryTypeId(dataType, axisCount);
out.print("INSERT INTO OGIS_GEOMETRY_COLUMNS(F_TABLE_SCHEMA,F_TABLE_NAME,F_GEOMETRY_COLUMN,G_TABLE_SCHEMA,G_TABLE_NAME,GEOMETRY_TYPE,COORD_DIMENSION,SRID) VALUES ('");
out.print(schemaName.toUpperCase());
out.print("', '");
out.print(tableName.toUpperCase());
out.print("','");
out.print(name.toUpperCase());
out.print("', '");
out.print(schemaName.toUpperCase());
out.print("', '");
out.print(tableName.toUpperCase());
out.print("',");
out.print(geometryType);
out.print(",");
out.print(axisCount);
out.print(",");
out.print("100");
out.print(srid);
out.println(");");
}
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class ArcSdeStGeometryFieldAdder method newField.
@Override
public ArcSdeStGeometryFieldDefinition newField(final AbstractJdbcRecordStore recordStore, final JdbcRecordDefinition recordDefinition, final String dbName, final String name, final String dbDataType, final int sqlType, final int length, final int scale, final boolean required, final String description) {
final JdbcRecordStoreSchema schema = recordDefinition.getSchema();
final PathName typePath = recordDefinition.getPathName();
final String owner = schema.getDbName();
final String tableName = recordDefinition.getDbTableName();
final String columnName = name.toUpperCase();
final int esriSrid = JdbcFieldAdder.getIntegerColumnProperty(schema, typePath, columnName, ArcSdeConstants.ESRI_SRID_PROPERTY);
if (esriSrid == -1) {
Logs.error(this, "Column not registered in SDE.ST_GEOMETRY table " + owner + "." + tableName + "." + name);
}
final int axisCount = JdbcFieldAdder.getIntegerColumnProperty(schema, typePath, columnName, JdbcFieldAdder.AXIS_COUNT);
if (axisCount == -1) {
Logs.error(this, "Column not found in SDE.GEOMETRY_COLUMNS table " + owner + "." + tableName + "." + name);
}
final DataType dataType = JdbcFieldAdder.getColumnProperty(schema, typePath, columnName, JdbcFieldAdder.GEOMETRY_TYPE);
if (dataType == null) {
Logs.error(this, "Column not found in SDE.GEOMETRY_COLUMNS table " + owner + "." + tableName + "." + name);
}
final ArcSdeSpatialReference spatialReference = JdbcFieldAdder.getColumnProperty(schema, typePath, columnName, ArcSdeConstants.SPATIAL_REFERENCE);
final GeometryFactory geometryFactory = JdbcFieldAdder.getColumnProperty(schema, typePath, columnName, JdbcFieldAdder.GEOMETRY_FACTORY);
final ArcSdeStGeometryFieldDefinition field = new ArcSdeStGeometryFieldDefinition(dbName, name, dataType, required, description, null, spatialReference, axisCount);
field.setProperty(FieldProperties.GEOMETRY_FACTORY, geometryFactory);
return field;
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class ArcSdeStGeometryRecordStoreExtension method loadColumnProperties.
private void loadColumnProperties(final RecordStoreSchema schema, final String schemaName, final Connection connection) throws SQLException {
final String sql = "SELECT GC.F_TABLE_NAME, GC.F_GEOMETRY_COLUMN, GC.SRID, GC.GEOMETRY_TYPE, GC.COORD_DIMENSION, SG.GEOMETRY_TYPE GEOMETRY_DATA_TYPE FROM SDE.GEOMETRY_COLUMNS GC LEFT OUTER JOIN SDE.ST_GEOMETRY_COLUMNS SG ON GC.F_TABLE_SCHEMA = SG.OWNER AND GC.F_TABLE_NAME = SG.TABLE_NAME WHERE GC.F_TABLE_SCHEMA = ?";
final PreparedStatement statement = connection.prepareStatement(sql);
try {
statement.setString(1, schemaName);
final ResultSet resultSet = statement.executeQuery();
try {
while (resultSet.next()) {
final String tableName = resultSet.getString(1);
final String columnName = resultSet.getString(2);
final PathName typePath = PathName.newPathName(PathUtil.toPath(schemaName, tableName));
final int esriSrid = resultSet.getInt(3);
JdbcFieldAdder.setColumnProperty(schema, typePath, columnName, ArcSdeConstants.ESRI_SRID_PROPERTY, esriSrid);
int axisCount = resultSet.getInt(5);
axisCount = Math.max(axisCount, 2);
JdbcFieldAdder.setColumnProperty(schema, typePath, columnName, JdbcFieldAdder.AXIS_COUNT, axisCount);
final ArcSdeSpatialReference spatialReference = ArcSdeSpatialReferenceCache.getSpatialReference(connection, schema, esriSrid);
JdbcFieldAdder.setColumnProperty(schema, typePath, columnName, ArcSdeConstants.SPATIAL_REFERENCE, spatialReference);
GeometryFactory geometryFactory = JdbcFieldAdder.getColumnProperty(schema, typePath, columnName, JdbcFieldAdder.GEOMETRY_FACTORY);
int srid = spatialReference.getCoordinateSystemId();
if (srid <= 0) {
srid = geometryFactory.getCoordinateSystemId();
}
axisCount = Math.min(axisCount, 3);
final double[] scales = spatialReference.getGeometryFactory().newScales(axisCount);
geometryFactory = GeometryFactory.fixed(srid, axisCount, scales);
JdbcFieldAdder.setColumnProperty(schema, typePath, columnName, JdbcFieldAdder.GEOMETRY_FACTORY, geometryFactory);
final int geometryType = resultSet.getInt(4);
JdbcFieldAdder.setColumnProperty(schema, typePath, columnName, JdbcFieldAdder.GEOMETRY_TYPE, ArcSdeConstants.getGeometryDataType(geometryType));
String geometryColumnType = resultSet.getString(6);
if (!Property.hasValue(geometryColumnType)) {
geometryColumnType = ArcSdeConstants.SDEBINARY;
}
JdbcFieldAdder.setColumnProperty(schema, typePath, columnName, ArcSdeConstants.GEOMETRY_COLUMN_TYPE, geometryColumnType);
}
} finally {
JdbcUtils.close(resultSet);
}
} finally {
JdbcUtils.close(statement);
}
}
Aggregations