use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class MapGuideServerFeatureIterator method newParser.
protected StaxReader newParser() {
if (this.closed) {
throw new NoSuchElementException();
} else {
this.currentRecordCount = 0;
if (this.supportsPaging) {
this.queryParameters.put("resultOffset", this.queryOffset + this.totalRecordCount);
if (this.serverLimit > 0) {
this.queryParameters.put("resultRecordCount", this.serverLimit);
}
}
final Resource resource = this.layer.getResource(this.queryParameters);
this.reader = StaxReader.newXmlReader(resource);
if (!this.reader.skipToStartElement("Features")) {
throw new NoSuchElementException();
}
return this.reader;
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class ArcGisResponse method refreshDo.
protected void refreshDo() {
final UrlResource serviceUrl = getServiceUrl();
final Resource resource;
if (isUseProxy()) {
final String url = serviceUrl.getUriString() + "%3ff%3djson";
final String username = serviceUrl.getUsername();
final String password = serviceUrl.getPassword();
resource = new UrlResource(url, username, password);
} else {
resource = serviceUrl.newUrlResource(Collections.singletonMap("f", "json"));
}
final MapEx newProperties = Json.toMap(resource);
initialize(newProperties);
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class XbaseRecordWriter method init.
protected void init() throws IOException {
if (!this.initialized) {
this.initialized = true;
final Resource resource = getResource();
if (resource != null) {
final Map<String, String> shortNames = getProperty("shortNames");
if (shortNames != null) {
this.shortNames = shortNames;
}
this.out = resource.newWritableByteChannel();
writeHeader();
}
final Resource codePageResource = resource.newResourceChangeExtension("cpg");
if (codePageResource != null) {
try (final Writer writer = codePageResource.newWriter()) {
writer.write(this.charset.name());
}
}
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class ShapefileRecordReader method initDo.
@Override
protected synchronized void initDo() {
if (this.in == null) {
try {
try {
if (this.resource.isFile()) {
final File file = this.resource.getFile();
this.in = new LittleEndianRandomAccessFile(file, "r");
} else {
this.in = new EndianInputStream(this.resource.getInputStream());
}
} catch (final IllegalArgumentException | UnsupportedOperationException e) {
this.in = new EndianInputStream(this.resource.getInputStream());
}
final Resource xbaseResource = this.resource.newResourceChangeExtension("dbf");
if (xbaseResource != null && xbaseResource.exists()) {
this.xbaseRecordReader = new XbaseRecordReader(xbaseResource, this.recordFactory, () -> updateRecordDefinition());
this.xbaseRecordReader.setTypeName(this.typeName);
this.xbaseRecordReader.setCloseFile(this.closeFile);
}
loadHeader();
int axisCount;
switch(this.shapeType) {
// 1
case ShapefileConstants.POINT_SHAPE:
// 3
case ShapefileConstants.POLYLINE_SHAPE:
// 5
case ShapefileConstants.POLYGON_SHAPE:
case // 8
ShapefileConstants.MULTI_POINT_SHAPE:
axisCount = 2;
break;
// 9
case ShapefileConstants.POINT_Z_SHAPE:
// 10
case ShapefileConstants.POLYLINE_Z_SHAPE:
// 19
case ShapefileConstants.POLYGON_Z_SHAPE:
case // 20
ShapefileConstants.MULTI_POINT_Z_SHAPE:
axisCount = 3;
break;
// 11
case ShapefileConstants.POINT_ZM_SHAPE:
// 13
case ShapefileConstants.POLYLINE_ZM_SHAPE:
// 15
case ShapefileConstants.POLYGON_ZM_SHAPE:
// 18
case ShapefileConstants.MULTI_POINT_ZM_SHAPE:
// 21
case ShapefileConstants.POINT_M_SHAPE:
// 23
case ShapefileConstants.POLYLINE_M_SHAPE:
// 25
case ShapefileConstants.POLYGON_M_SHAPE:
case // 28
ShapefileConstants.MULTI_POINT_M_SHAPE:
axisCount = 4;
break;
default:
throw new RuntimeException("Unknown shape type:" + this.shapeType);
}
this.geometryFactory = getProperty(IoConstants.GEOMETRY_FACTORY);
if (this.geometryFactory == null) {
this.geometryFactory = GeometryFactory.floating(this.resource, axisCount);
}
if (this.geometryFactory == null) {
this.geometryFactory = GeometryFactory.floating(0, axisCount);
}
setProperty(IoConstants.GEOMETRY_FACTORY, this.geometryFactory);
if (this.xbaseRecordReader != null) {
this.xbaseRecordReader.hasNext();
}
if (this.recordDefinition == null) {
this.recordDefinition = Records.newGeometryRecordDefinition();
}
this.recordDefinition.setGeometryFactory(this.geometryFactory);
} catch (final IOException e) {
throw new RuntimeException("Error initializing mappedFile " + this.resource, e);
}
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class ShapefileZip method newRecordWriter.
@Override
public RecordWriter newRecordWriter(final String baseName, final RecordDefinition recordDefinition, final OutputStream outputStream, final Charset charset) {
File directory;
try {
directory = FileUtil.newTempDirectory(baseName, "zipDir");
} catch (final Throwable e) {
throw new RuntimeException("Unable to create temporary directory", e);
}
final Resource tempResource = new PathResource(new File(directory, baseName + ".shp"));
final RecordWriter shapeWriter = new ShapefileRecordWriter(recordDefinition, tempResource);
return new ZipRecordWriter(directory, shapeWriter, outputStream);
}
Aggregations