use of com.revolsys.record.io.format.esri.gdb.xml.model.SpatialReference in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method getSpatialReference.
public static SpatialReference getSpatialReference(final GeometryFactory geometryFactory) {
if (geometryFactory == null || geometryFactory.getCoordinateSystemId() == 0) {
return null;
} else {
final String wkt = getSingleThreadResult(() -> {
return EsriFileGdb.getSpatialReferenceWkt(geometryFactory.getCoordinateSystemId());
});
final SpatialReference spatialReference = SpatialReference.get(geometryFactory, wkt);
return spatialReference;
}
}
use of com.revolsys.record.io.format.esri.gdb.xml.model.SpatialReference in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method newTableRecordDefinition.
private RecordDefinitionImpl newTableRecordDefinition(final DETable deTable) {
synchronized (this.apiSync) {
synchronized (API_SYNC) {
final Geodatabase geodatabase = getGeodatabase();
if (geodatabase == null) {
return null;
} else {
try {
String schemaCatalogPath = deTable.getParentCatalogPath();
SpatialReference spatialReference;
if (deTable instanceof DEFeatureClass) {
final DEFeatureClass featureClass = (DEFeatureClass) deTable;
spatialReference = featureClass.getSpatialReference();
} else {
spatialReference = null;
}
PathName schemaPath = toPath(schemaCatalogPath);
final RecordStoreSchema schema = newSchema(schemaPath, spatialReference);
if (schemaPath.equals(this.defaultSchemaPath)) {
if (!(deTable instanceof DEFeatureClass)) {
schemaCatalogPath = "\\";
deTable.setCatalogPath("\\" + deTable.getName());
}
} else if (schemaPath.equals("")) {
schemaPath = this.defaultSchemaPath;
}
for (final Field field : deTable.getFields()) {
final String fieldName = field.getName();
final CodeTable codeTable = getCodeTableByFieldName(fieldName);
if (codeTable instanceof FileGdbDomainCodeTable) {
final FileGdbDomainCodeTable domainCodeTable = (FileGdbDomainCodeTable) codeTable;
field.setDomain(domainCodeTable.getDomain());
}
}
final String tableDefinition = EsriGdbXmlSerializer.toString(deTable);
try {
final Table table = geodatabase.createTable(tableDefinition, schemaCatalogPath);
geodatabase.closeTable(table);
table.delete();
final RecordDefinitionImpl recordDefinition = getRecordDefinition(PathName.newPathName(schemaPath), schemaCatalogPath, tableDefinition);
initRecordDefinition(recordDefinition);
schema.addElement(recordDefinition);
return recordDefinition;
} catch (final Throwable t) {
throw new RuntimeException("Unable to create table " + deTable.getCatalogPath(), t);
}
} finally {
releaseGeodatabase();
}
}
}
}
}
use of com.revolsys.record.io.format.esri.gdb.xml.model.SpatialReference in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method refreshSchemaElements.
@Override
protected Map<PathName, ? extends RecordStoreSchemaElement> refreshSchemaElements(final RecordStoreSchema schema) {
synchronized (this.apiSync) {
synchronized (API_SYNC) {
final Map<PathName, RecordStoreSchemaElement> elementsByPath = new TreeMap<>();
final Geodatabase geodatabase = getGeodatabase();
if (geodatabase != null) {
try {
final PathName schemaPath = schema.getPathName();
final String schemaCatalogPath = getCatalogPath(schema);
final VectorOfWString childDatasets = getChildDatasets(geodatabase, schemaCatalogPath, "Feature Dataset");
if (childDatasets != null) {
for (int i = 0; i < childDatasets.size(); i++) {
final String childCatalogPath = childDatasets.get(i);
final PathName childPath = toPath(childCatalogPath);
RecordStoreSchema childSchema = schema.getSchema(childPath);
if (childSchema == null) {
childSchema = newFeatureDatasetSchema(schema, childPath);
} else {
if (childSchema.isInitialized()) {
childSchema.refresh();
}
}
elementsByPath.put(childPath, childSchema);
}
}
if (schemaPath.isParentOf(this.defaultSchemaPath) && !elementsByPath.containsKey(this.defaultSchemaPath)) {
final SpatialReference spatialReference = getSpatialReference(getGeometryFactory());
final RecordStoreSchema childSchema = newSchema(this.defaultSchemaPath, spatialReference);
elementsByPath.put(this.defaultSchemaPath, childSchema);
}
if (schema.equalPath(this.defaultSchemaPath)) {
refreshSchemaRecordDefinitions(elementsByPath, schemaPath, "\\", "Feature Class");
refreshSchemaRecordDefinitions(elementsByPath, schemaPath, "\\", "Table");
}
refreshSchemaRecordDefinitions(elementsByPath, schemaPath, schemaCatalogPath, "Feature Class");
refreshSchemaRecordDefinitions(elementsByPath, schemaPath, schemaCatalogPath, "Table");
} finally {
releaseGeodatabase();
}
}
return elementsByPath;
}
}
}
use of com.revolsys.record.io.format.esri.gdb.xml.model.SpatialReference in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method newTableRecordDefinition.
private RecordDefinition newTableRecordDefinition(final RecordDefinition recordDefinition) {
synchronized (this.apiSync) {
synchronized (API_SYNC) {
final GeometryFactory geometryFactory = recordDefinition.getGeometryFactory();
final SpatialReference spatialReference = getSpatialReference(geometryFactory);
final DETable deTable = EsriXmlRecordDefinitionUtil.getDETable(recordDefinition, spatialReference, this.createLengthField, this.createAreaField);
final RecordDefinitionImpl tableRecordDefinition = newTableRecordDefinition(deTable);
final String idFieldName = recordDefinition.getIdFieldName();
if (idFieldName != null) {
tableRecordDefinition.setIdFieldName(idFieldName);
}
return tableRecordDefinition;
}
}
}
Aggregations