Search in sources :

Example 6 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem 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(");");
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) FieldDefinition(com.revolsys.record.schema.FieldDefinition) DataType(com.revolsys.datatype.DataType) PrintWriter(java.io.PrintWriter)

Example 7 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class LasPointCloudHeader method toMap.

@Override
public MapEx toMap() {
    final MapEx map = new LinkedHashMapEx();
    addToMap(map, "version", this.version);
    addToMap(map, "fileSourceId", this.fileSourceId, 0);
    addToMap(map, "systemIdentifier", this.systemIdentifier);
    addToMap(map, "generatingSoftware", this.generatingSoftware);
    addToMap(map, "date", this.date);
    if (this.geometryFactory != null) {
        final int coordinateSystemId = this.geometryFactory.getCoordinateSystemId();
        if (coordinateSystemId > 0) {
            addToMap(map, "coordinateSystemId", coordinateSystemId);
        }
        final CoordinateSystem coordinateSystem = this.geometryFactory.getCoordinateSystem();
        if (coordinateSystem != null) {
            addToMap(map, "coordinateSystemName", coordinateSystem.getCoordinateSystemName());
            addToMap(map, "coordinateSystem", coordinateSystem.toEsriWktCs());
        }
    }
    addToMap(map, "boundingBox", getBoundingBox());
    addToMap(map, "headerSize", this.headerSize);
    if (this.laszip) {
        addToMap(map, "laszip", this.lasZipHeader);
    }
    addToMap(map, "pointRecordsOffset", this.pointRecordsOffset, 0);
    addToMap(map, "pointFormat", this.pointFormat.getId());
    addToMap(map, "pointCount", this.pointCount);
    int returnCount = 15;
    if (this.pointFormat.getId() < 6) {
        returnCount = 5;
    }
    int returnIndex = 0;
    final List<Long> pointCountByReturn = new ArrayList<>();
    for (final long pointCountForReturn : this.pointCountByReturn) {
        if (returnIndex < returnCount) {
            pointCountByReturn.add(pointCountForReturn);
        }
        returnIndex++;
    }
    addToMap(map, "pointCountByReturn", pointCountByReturn);
    return map;
}
Also used : MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ArrayList(java.util.ArrayList) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint)

Example 8 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class LasPointCloudHeader method setGeometryFactory.

protected void setGeometryFactory(final GeometryFactory geometryFactory) {
    if (geometryFactory != null) {
        final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
        double scaleX = geometryFactory.getScaleX();
        if (scaleX == 0) {
            scaleX = 1000;
        }
        double scaleY = geometryFactory.getScaleY();
        if (scaleY == 0) {
            scaleY = 1000;
        }
        double scaleZ = geometryFactory.getScaleZ();
        if (scaleZ == 0) {
            scaleZ = 1000;
        }
        final double offsetX = geometryFactory.getOffsetX();
        final double offsetY = geometryFactory.getOffsetY();
        final double offsetZ = geometryFactory.getOffsetZ();
        this.geometryFactory = GeometryFactory.newWithOffsets(coordinateSystem, offsetX, scaleX, offsetY, scaleY, offsetZ, scaleZ);
        LasProjection.setCoordinateSystem(this, coordinateSystem);
    }
}
Also used : CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem)

Example 9 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class LasProjection method convertGeoTiffProjection.

@SuppressWarnings("unused")
private static Object convertGeoTiffProjection(final LasPointCloudHeader header, final byte[] bytes) {
    try {
        final List<Double> doubleParams = new ArrayList<>();
        {
            final LasVariableLengthRecord doubleParamsProperty = header.getLasProperty(new Pair<>(LASF_PROJECTION, LASF_PROJECTION_TIFF_GEO_DOUBLE_PARAMS));
            if (doubleParamsProperty != null) {
                final byte[] doubleParamBytes = doubleParamsProperty.getBytes();
                final ByteBuffer buffer = ByteBuffer.wrap(doubleParamBytes);
                buffer.order(ByteOrder.LITTLE_ENDIAN);
                for (int i = 0; i < doubleParamBytes.length / 8; i++) {
                    final double value = buffer.getDouble();
                    doubleParams.add(value);
                }
            }
        }
        byte[] asciiParamsBytes;
        {
            final LasVariableLengthRecord asciiParamsProperty = header.getLasProperty(new Pair<>(LASF_PROJECTION, LASF_PROJECTION_TIFF_GEO_ASCII_PARAMS));
            if (asciiParamsProperty == null) {
                asciiParamsBytes = new byte[0];
            } else {
                asciiParamsBytes = asciiParamsProperty.getBytes();
            }
        }
        final Map<Integer, Object> properties = new LinkedHashMap<>();
        final ByteBuffer buffer = ByteBuffer.wrap(bytes);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        final int keyDirectoryVersion = Buffers.getLEUnsignedShort(buffer);
        final int keyRevision = Buffers.getLEUnsignedShort(buffer);
        final int minorRevision = Buffers.getLEUnsignedShort(buffer);
        final int numberOfKeys = Buffers.getLEUnsignedShort(buffer);
        for (int i = 0; i < numberOfKeys; i++) {
            final int keyId = Buffers.getLEUnsignedShort(buffer);
            final int tagLocation = Buffers.getLEUnsignedShort(buffer);
            final int count = Buffers.getLEUnsignedShort(buffer);
            final int offset = Buffers.getLEUnsignedShort(buffer);
            if (tagLocation == 0) {
                properties.put(keyId, offset);
            } else if (tagLocation == LASF_PROJECTION_TIFF_GEO_DOUBLE_PARAMS) {
                final double value = doubleParams.get(offset);
                properties.put(keyId, value);
            } else if (tagLocation == LASF_PROJECTION_TIFF_GEO_ASCII_PARAMS) {
                final String value = new String(asciiParamsBytes, offset, count, StandardCharsets.US_ASCII);
                properties.put(keyId, value);
            }
        }
        CoordinateSystem coordinateSystem = null;
        int coordinateSystemId = Maps.getInteger(properties, TiffImage.PROJECTED_COORDINATE_SYSTEM_ID, 0);
        if (coordinateSystemId == 0) {
            coordinateSystemId = Maps.getInteger(properties, TiffImage.GEOGRAPHIC_COORDINATE_SYSTEM_ID, 0);
            if (coordinateSystemId != 0) {
                coordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(coordinateSystemId);
            }
        } else if (coordinateSystemId <= 0 || coordinateSystemId == 32767) {
            final int geoSrid = Maps.getInteger(properties, TiffImage.GEOGRAPHIC_COORDINATE_SYSTEM_ID, 0);
            if (geoSrid != 0) {
                if (geoSrid > 0 && geoSrid < 32767) {
                    final GeographicCoordinateSystem geographicCoordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(geoSrid);
                    final String name = "unknown";
                    final CoordinateOperationMethod coordinateOperationMethod = TiffImage.getProjection(properties);
                    final Map<ParameterName, ParameterValue> parameters = new LinkedHashMap<>();
                    TiffImage.addDoubleParameter(parameters, ParameterNames.STANDARD_PARALLEL_1, properties, TiffImage.STANDARD_PARALLEL_1_KEY);
                    TiffImage.addDoubleParameter(parameters, ParameterNames.STANDARD_PARALLEL_2, properties, TiffImage.STANDARD_PARALLEL_2_KEY);
                    TiffImage.addDoubleParameter(parameters, ParameterNames.CENTRAL_MERIDIAN, properties, TiffImage.LONGITUDE_OF_CENTER_2_KEY);
                    TiffImage.addDoubleParameter(parameters, ParameterNames.LATITUDE_OF_ORIGIN, properties, TiffImage.LATITUDE_OF_CENTER_2_KEY);
                    TiffImage.addDoubleParameter(parameters, ParameterNames.FALSE_EASTING, properties, TiffImage.FALSE_EASTING_KEY);
                    TiffImage.addDoubleParameter(parameters, ParameterNames.FALSE_NORTHING, properties, TiffImage.FALSE_NORTHING_KEY);
                    final LinearUnit linearUnit = TiffImage.getLinearUnit(properties);
                    final ProjectedCoordinateSystem projectedCoordinateSystem = new ProjectedCoordinateSystem(coordinateSystemId, name, geographicCoordinateSystem, coordinateOperationMethod, parameters, linearUnit);
                    coordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(projectedCoordinateSystem);
                }
            }
        } else {
            coordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(coordinateSystemId);
        }
        header.setCoordinateSystemInternal(coordinateSystem);
        return coordinateSystem;
    } catch (final IOException e) {
        throw Exceptions.wrap(e);
    }
}
Also used : LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) ArrayList(java.util.ArrayList) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer) LinkedHashMap(java.util.LinkedHashMap) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Pair(com.revolsys.util.Pair)

Example 10 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method getProjectedCoordinateSystems.

public static List<ProjectedCoordinateSystem> getProjectedCoordinateSystems() {
    final List<ProjectedCoordinateSystem> coordinateSystems = new ArrayList<>();
    for (final CoordinateSystem coordinateSystem : coordinateSystemsByName.values()) {
        if (coordinateSystem instanceof ProjectedCoordinateSystem) {
            final ProjectedCoordinateSystem projectedCoordinateSystem = (ProjectedCoordinateSystem) coordinateSystem;
            coordinateSystems.add(projectedCoordinateSystem);
        }
    }
    return coordinateSystems;
}
Also used : ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeocentricCoordinateSystem(com.revolsys.geometry.cs.GeocentricCoordinateSystem) CompoundCoordinateSystem(com.revolsys.geometry.cs.CompoundCoordinateSystem) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) EngineeringCoordinateSystem(com.revolsys.geometry.cs.EngineeringCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) ArrayList(java.util.ArrayList)

Aggregations

CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)51 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)28 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)25 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 BoundingBox (com.revolsys.geometry.model.BoundingBox)11 Point (com.revolsys.geometry.model.Point)8 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)7 EngineeringCoordinateSystem (com.revolsys.geometry.cs.EngineeringCoordinateSystem)7 GeocentricCoordinateSystem (com.revolsys.geometry.cs.GeocentricCoordinateSystem)7 VerticalCoordinateSystem (com.revolsys.geometry.cs.VerticalCoordinateSystem)7 ArrayList (java.util.ArrayList)6 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)5 Map (java.util.Map)5 DataType (com.revolsys.datatype.DataType)4 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)4 Record (com.revolsys.record.Record)4 FieldDefinition (com.revolsys.record.schema.FieldDefinition)4 PrintWriter (java.io.PrintWriter)4 IntHashMap (com.revolsys.collection.map.IntHashMap)3 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)3