use of com.revolsys.spring.resource.ClassPathResource in project com.revolsys.open by revolsys.
the class TestUtil method doTestGeometry.
public static void doTestGeometry(final Class<?> clazz, final String file) {
boolean valid = true;
final Resource resource = new ClassPathResource(file, clazz);
try (Reader<Record> reader = RecordReader.newRecordReader(resource)) {
int i = 0;
for (final Record object : reader) {
final int srid = object.getInteger("srid");
final int axisCount = object.getInteger("axisCount");
final double scaleXy = object.getInteger("scaleXy");
final double scaleZ = object.getInteger("scaleZ");
final double[] scales = { scaleXy, scaleXy, scaleZ };
final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scales);
final String wkt = object.getValue("wkt");
final Geometry geometry = geometryFactory.geometry(wkt);
valid &= equalsExpectedWkt(i, object, geometry);
final CoordinateSystem coordinateSystem = geometry.getCoordinateSystem();
GeometryFactory otherGeometryFactory;
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projectedCoordinateSystem = (ProjectedCoordinateSystem) coordinateSystem;
otherGeometryFactory = GeometryFactory.fixed(projectedCoordinateSystem.getCoordinateSystemId(), axisCount, scales);
} else {
otherGeometryFactory = GeometryFactory.fixed(3005, axisCount, scales);
}
final Geometry convertedGeometry = geometry.convertGeometry(otherGeometryFactory);
final Geometry convertedBackGeometry = convertedGeometry.convertGeometry(geometryFactory);
valid &= equalsExpectedGeometry(i, convertedBackGeometry, geometry);
i++;
}
}
if (!valid) {
Assert.fail("Has Errors");
}
}
use of com.revolsys.spring.resource.ClassPathResource in project com.revolsys.open by revolsys.
the class Fonts method init.
private static void init() {
synchronized (SYNC) {
if (!initialized) {
try {
final GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
final ClassPathResource resource = new ClassPathResource("com/revolsys/fonts/fontawesome-webfont.ttf");
final InputStream inputStream = resource.newInputStream();
final Font font = Font.createFont(Font.TRUETYPE_FONT, inputStream);
environment.registerFont(font);
} catch (IOException | FontFormatException e) {
}
initialized = true;
}
}
}
use of com.revolsys.spring.resource.ClassPathResource in project com.revolsys.open by revolsys.
the class SvgMarker method postSetMarkerType.
@Override
protected void postSetMarkerType() {
final String markerType = getMarkerType();
this.symbol = SymbolLibrary.findSymbol(markerType);
final Resource resource = new ClassPathResource(markerType + ".svg");
try {
final String uri = resource.getUriString();
this.document = SvgUtil.newDocument(uri);
this.transcoderInput = new TranscoderInput(this.document);
this.transcoderInput.setURI(uri);
this.icon = new SvgIcon(this.document, 16, 16);
} catch (final Throwable e) {
this.document = null;
Logs.error(this, "Cannot open :" + resource, e);
}
}
use of com.revolsys.spring.resource.ClassPathResource in project com.revolsys.open by revolsys.
the class SaifReader method loadExportedObjects.
/**
* Load the exported objects for the SAIF archive.
*
* @throws IOException If there was an I/O error.
*/
@SuppressWarnings("unchecked")
private void loadExportedObjects() throws IOException {
final boolean setNames = this.includeTypeNames.isEmpty();
final ClassPathResource resource = new ClassPathResource("com/revolsys/io/saif/saifzip.csn");
final RecordDefinitionFactory schema = new SaifSchemaReader().loadSchema(resource);
final OsnReader reader = getOsnReader(schema, this.factory, "/exports.dir");
try {
final Map<String, String> names = new TreeMap<>();
if (reader.hasNext()) {
this.exportedObjects = reader.next();
final Set<Record> handles = (Set<Record>) this.exportedObjects.getValue("handles");
for (final Record exportedObject : handles) {
final String fileName = (String) exportedObject.getValue("objectSubset");
if (fileName != null && !fileName.equals("globmeta.osn")) {
String typePath = getTypeName(fileName);
if (typePath == null) {
final String name = (String) exportedObject.getValue("type");
typePath = PathCache.getName(name);
if (!this.fileNameTypeNameMap.containsKey(fileName)) {
this.fileNameTypeNameMap.put(fileName, typePath);
this.typePathFileNameMap.put(typePath, fileName);
}
}
if (setNames && !fileName.equals("metdat00.osn") && !fileName.equals("refsys00.osn")) {
names.put(typePath.toString(), typePath);
}
}
}
if (setNames) {
this.typePaths = new ArrayList<>(names.values());
} else {
this.typePaths = new ArrayList<>(this.includeTypeNames);
}
this.typePaths.removeAll(this.excludeTypeNames);
}
} finally {
reader.close();
}
}
use of com.revolsys.spring.resource.ClassPathResource in project com.revolsys.open by revolsys.
the class IntersectionTest method suite.
public static Test suite() {
final TestSuite suite = new TestSuite("Intersection");
int index = 0;
try (MapReader reader = MapReader.newMapReader(new ClassPathResource("/com/revolsys/jts/test/geometry/operation/intersection.tsv"))) {
for (final MapEx map : reader) {
index++;
if (map.getString("active").equalsIgnoreCase("true")) {
final String description = map.getString("description");
final int srid = map.getInteger("srid", 0);
final int axisCount = map.getInteger("axisCount", 2);
final double scaleXy = map.getDouble("scaleXy", 0.0);
final double scaleZ = map.getDouble("scaleZ", 0.0);
final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scaleXy, scaleXy, scaleZ);
final String geometry1Wkt = map.getString("geometry1");
final Geometry geometry1 = newGeometry(geometryFactory, geometry1Wkt);
final String geometry2Wkt = map.getString("geometry2");
final Geometry geometry2 = newGeometry(geometryFactory, geometry2Wkt);
final String expectedIntersectionWkt = map.getString("expectedIntersection");
final Geometry expectedIntersection = newGeometry(geometryFactory, expectedIntersectionWkt);
final IntersectionTest test = new IntersectionTest(index, description, geometry1, geometry2, expectedIntersection);
suite.addTest(test);
}
}
}
return suite;
}
Aggregations