Search in sources :

Example 21 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class ArcGisRestCatalog method getName.

@Override
public String getName() {
    String name = super.getName();
    if (name == null) {
        final PathName pathName = getPathName();
        if (pathName == null || pathName.equals("/")) {
            final UrlResource resourceUrl = getServiceUrl();
            try {
                final URI uri = resourceUrl.getUri();
                return uri.getHost();
            } catch (final Throwable e) {
                return "???";
            }
        } else {
            name = pathName.getName();
            setName(name);
        }
    }
    return name;
}
Also used : UrlResource(com.revolsys.spring.resource.UrlResource) PathName(com.revolsys.io.PathName) URI(java.net.URI)

Example 22 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class MapService method getMapService.

public static MapService getMapService(String url) {
    url = url.replaceAll("/*MapServer/*(\\?.*)?", "") + "/MapServer";
    final ArcGisRestCatalog catalog = ArcGisRestCatalog.newArcGisRestCatalog(url);
    final PathName path = PathName.newPathName(url.substring(catalog.getServiceUrl().toString().length()));
    final MapService service = catalog.getWebServiceResource(path, MapService.class);
    return service;
}
Also used : ArcGisRestCatalog(com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog) PathName(com.revolsys.io.PathName)

Example 23 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class FeatureSource method newLayer.

private FeatureLayer newLayer(final String name, final MapEx element, final MapEx complexType) {
    if (!"true".equals(getString(complexType, "@abstract"))) {
        final PathName pathName = getPathName();
        final PathName layerPathName = pathName.newChild(name);
        final RecordDefinitionImpl recordDefinition = new RecordDefinitionImpl(layerPathName);
        GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
        final MapEx complexContent = getValue(complexType, "xs:complexContent");
        final MapEx extension = getValue(complexContent, "xs:extension");
        if ("gml:AbstractFeatureType".equals(getString(extension, "@base"))) {
            final MapEx sequence = getValue(extension, "xs:sequence");
            final List<MapEx> elements = sequence.getValue("xs:element");
            for (final MapEx fieldElement : elements) {
                final String fieldName = getString(fieldElement, "@name");
                final boolean required = !"0".equals(getString(fieldElement, "@minOccurs"));
                DataType dataType = DataTypes.STRING;
                final MapEx simpleFieldType = getValue(fieldElement, "xs:simpleType");
                if (simpleFieldType == null) {
                    final String fieldType = getString(fieldElement, "@type");
                    if ("gml:AbstractGeometryType".equals(fieldType)) {
                        final String geometryTypes = getString(fieldElement, "@fdo:geometryTypes");
                        for (final String geometryType : geometryTypes.split(" ")) {
                            final DataType geometryDataType = DataTypes.getDataType(geometryType);
                            if (geometryDataType != DataTypes.OBJECT) {
                                if (dataType == DataTypes.STRING) {
                                    dataType = geometryDataType;
                                } else if (dataType == DataTypes.GEOMETRY) {
                                } else if (geometryDataType == DataTypes.GEOMETRY) {
                                    dataType = DataTypes.GEOMETRY;
                                } else if (geometryDataType == DataTypes.GEOMETRY_COLLECTION) {
                                    dataType = DataTypes.GEOMETRY;
                                } else if (dataType.equals(DataTypes.POINT)) {
                                    if (geometryDataType.equals(DataTypes.POINT)) {
                                    } else if (geometryDataType.equals(DataTypes.MULTI_POINT)) {
                                        dataType = DataTypes.MULTI_POINT;
                                    } else {
                                        dataType = DataTypes.GEOMETRY;
                                    }
                                } else if (dataType.equals(DataTypes.MULTI_POINT)) {
                                    if (geometryDataType.equals(DataTypes.POINT)) {
                                    } else if (geometryDataType.equals(DataTypes.MULTI_POINT)) {
                                    } else {
                                        dataType = DataTypes.GEOMETRY;
                                    }
                                } else if (dataType.equals(DataTypes.LINE_STRING)) {
                                    if (geometryDataType.equals(DataTypes.LINE_STRING)) {
                                    } else if (geometryDataType.equals(DataTypes.MULTI_LINE_STRING)) {
                                        dataType = DataTypes.MULTI_LINE_STRING;
                                    } else {
                                        dataType = DataTypes.GEOMETRY;
                                    }
                                } else if (dataType.equals(DataTypes.MULTI_LINE_STRING)) {
                                    if (geometryDataType.equals(DataTypes.LINE_STRING)) {
                                    } else if (geometryDataType.equals(DataTypes.MULTI_LINE_STRING)) {
                                    } else {
                                        dataType = DataTypes.GEOMETRY;
                                    }
                                } else if (dataType.equals(DataTypes.POLYGON)) {
                                    if (geometryDataType.equals(DataTypes.POLYGON)) {
                                    } else if (geometryDataType.equals(DataTypes.MULTI_POLYGON)) {
                                        dataType = DataTypes.MULTI_POLYGON;
                                    } else {
                                        dataType = DataTypes.GEOMETRY;
                                    }
                                } else if (dataType.equals(DataTypes.MULTI_POLYGON)) {
                                    if (geometryDataType.equals(DataTypes.POLYGON)) {
                                    } else if (geometryDataType.equals(DataTypes.MULTI_POLYGON)) {
                                    } else {
                                        dataType = DataTypes.GEOMETRY;
                                    }
                                }
                            }
                        }
                        if (dataType == DataTypes.STRING) {
                            dataType = DataTypes.GEOMETRY;
                        }
                        int axisCount = 2;
                        if ("true".equals(getString(fieldElement, "@fdo:hasMeasure"))) {
                            axisCount = 4;
                        } else if ("true".equals(getString(fieldElement, "@fdo:hasElevation"))) {
                            axisCount = 3;
                        }
                        final String srsName = getString(fieldElement, "@fdo:srsName");
                        if (Property.hasValue(srsName)) {
                            final Integer coordinateSystemId = Maps.getInteger(this.coordinateSystemIdBySrsName, srsName);
                            if (coordinateSystemId == null) {
                                try {
                                    final Map<String, Object> csParameters = Collections.singletonMap("CSCODE", srsName);
                                    final MapGuideWebService webService = getWebService();
                                    final Resource wktResource = webService.getResource("CS.CONVERTCOORDINATESYSTEMCODETOWKT", null, csParameters);
                                    final String wkt = wktResource.contentsAsString();
                                    geometryFactory = GeometryFactory.floating(wkt, axisCount);
                                } catch (final Throwable e) {
                                }
                            } else {
                                geometryFactory = GeometryFactory.floating(coordinateSystemId, axisCount);
                            }
                        }
                    }
                } else {
                    final MapEx restriction = getValue(simpleFieldType, "xs:restriction");
                    if (restriction != null) {
                        final String fieldBase = getString(restriction, "@base");
                        dataType = DataTypes.getDataType(fieldBase.replace("xs:", ""));
                    }
                }
                if (dataType != null) {
                    recordDefinition.addField(fieldName, dataType, required);
                }
            }
            recordDefinition.setGeometryFactory(geometryFactory);
            final FeatureLayer layer = new FeatureLayer(this, recordDefinition);
            return layer;
        }
    }
    return null;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) WebServiceResource(com.revolsys.webservice.WebServiceResource) Resource(com.revolsys.spring.resource.Resource) RecordDefinitionImpl(com.revolsys.record.schema.RecordDefinitionImpl) DataType(com.revolsys.datatype.DataType) PathName(com.revolsys.io.PathName)

Example 24 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class WebServiceResource method getPathName.

default PathName getPathName() {
    final WebServiceResource parent = getParent();
    if (parent == null) {
        return PathName.ROOT;
    } else {
        final PathName parentPathName = parent.getPathName();
        final String name = getPathElement();
        return parentPathName.newChild(name);
    }
}
Also used : PathName(com.revolsys.io.PathName)

Example 25 with PathName

use of com.revolsys.io.PathName in project com.revolsys.open by revolsys.

the class FileGdbRecordStore method deleteRecord.

boolean deleteRecord(final Table table, final Record record) {
    final Integer objectId = record.getInteger("OBJECTID");
    final PathName typePath = record.getPathName();
    if (objectId != null && table != null) {
        synchronized (table) {
            final String whereClause = "OBJECTID=" + objectId;
            try (final FileGdbEnumRowsIterator rows = search(typePath, table, "OBJECTID", whereClause, false)) {
                for (final Row row : rows) {
                    synchronized (this.apiSync) {
                        final boolean loadOnly = isTableLocked(typePath);
                        if (loadOnly) {
                            table.setLoadOnlyMode(false);
                        }
                        table.deleteRow(row);
                        if (loadOnly) {
                            table.setLoadOnlyMode(true);
                        }
                    }
                    record.setState(RecordState.DELETED);
                    addStatistic("Delete", record);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : PathName(com.revolsys.io.PathName) VectorOfWString(com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString) Row(com.revolsys.gis.esri.gdb.file.capi.swig.Row)

Aggregations

PathName (com.revolsys.io.PathName)64 FieldDefinition (com.revolsys.record.schema.FieldDefinition)15 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)14 DataType (com.revolsys.datatype.DataType)13 RecordDefinition (com.revolsys.record.schema.RecordDefinition)13 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)12 RecordStoreSchema (com.revolsys.record.schema.RecordStoreSchema)11 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)9 RecordStoreSchemaElement (com.revolsys.record.schema.RecordStoreSchemaElement)7 ArrayList (java.util.ArrayList)7 TreeMap (java.util.TreeMap)7 MapEx (com.revolsys.collection.map.MapEx)5 ResultSet (java.sql.ResultSet)5 Geodatabase (com.revolsys.gis.esri.gdb.file.capi.swig.Geodatabase)4 Identifier (com.revolsys.identifier.Identifier)4 JdbcConnection (com.revolsys.jdbc.JdbcConnection)4 Record (com.revolsys.record.Record)4 File (java.io.File)4 PreparedStatement (java.sql.PreparedStatement)4 Geometry (com.revolsys.geometry.model.Geometry)3