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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations