use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class ModuleImport method getApplicationContext.
protected GenericApplicationContext getApplicationContext(final BeanDefinitionRegistry parentRegistry) {
if (this.applicationContext == null) {
this.applicationContext = new GenericApplicationContext();
if (parentRegistry instanceof ResourceLoader) {
final ResourceLoader resourceLoader = (ResourceLoader) parentRegistry;
final ClassLoader classLoader = resourceLoader.getClassLoader();
this.applicationContext.setClassLoader(classLoader);
}
AnnotationConfigUtils.registerAnnotationConfigProcessors(this.applicationContext, null);
final DefaultListableBeanFactory beanFactory = this.applicationContext.getDefaultListableBeanFactory();
final BeanFactory parentBeanFactory = (BeanFactory) parentRegistry;
for (final String beanName : parentRegistry.getBeanDefinitionNames()) {
final BeanDefinition beanDefinition = parentRegistry.getBeanDefinition(beanName);
final String beanClassName = beanDefinition.getBeanClassName();
if (beanClassName != null) {
if (beanClassName.equals(AttributeMap.class.getName())) {
registerTargetBeanDefinition(this.applicationContext, parentBeanFactory, beanName, beanName);
this.beanNamesNotToExport.add(beanName);
} else if (beanClassName.equals(MapFactoryBean.class.getName())) {
final PropertyValue targetMapClass = beanDefinition.getPropertyValues().getPropertyValue("targetMapClass");
if (targetMapClass != null) {
final Object mapClass = targetMapClass.getValue();
if (AttributeMap.class.getName().equals(mapClass)) {
registerTargetBeanDefinition(this.applicationContext, parentBeanFactory, beanName, beanName);
this.beanNamesNotToExport.add(beanName);
}
}
}
}
}
beanFactory.addPropertyEditorRegistrar(this.resourceEditorRegistrar);
final AttributesBeanConfigurer attributesConfig = new AttributesBeanConfigurer(this.applicationContext, this.parameters);
this.applicationContext.addBeanFactoryPostProcessor(attributesConfig);
for (final String beanName : this.importBeanNames) {
registerTargetBeanDefinition(this.applicationContext, parentBeanFactory, beanName, beanName);
this.beanNamesNotToExport.add(beanName);
}
for (final Entry<String, String> entry : this.importBeanAliases.entrySet()) {
final String beanName = entry.getKey();
final String aliasName = entry.getValue();
registerTargetBeanDefinition(this.applicationContext, parentBeanFactory, beanName, aliasName);
this.beanNamesNotToExport.add(aliasName);
}
final XmlBeanDefinitionReader beanReader = new XmlBeanDefinitionReader(this.applicationContext);
for (final Resource resource : this.resources) {
beanReader.loadBeanDefinitions(resource);
}
this.applicationContext.refresh();
}
return this.applicationContext;
}
use of com.revolsys.spring.resource.Resource 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.Resource in project com.revolsys.open by revolsys.
the class CreateIndex method main.
public static void main(final String[] args) {
SymbolLibrary.findSymbol("maki/police");
final Resource makiFile = new UrlResource("https://www.mapbox.com/maki/www/maki.json");
final List<MapEx> symbolList = Json.toMapList(makiFile);
final SymbolLibrary symbolLibrary = new SymbolLibrary("maki", "Maki");
for (final MapEx symbolMap : symbolList) {
final String name = "maki/" + symbolMap.getString("icon");
final String title = symbolMap.getString("name");
symbolLibrary.addSymbolSvg(name, title);
}
final File symbolLibraryFile = new File("src/main/resources/META-INF/com.revolsys.swing.map.symbol.SymbolLibrary.json");
MapObjectFactory.write(symbolLibraryFile, symbolLibrary);
final SymbolLibrary symbolLibrary2 = MapObjectFactory.toObject(symbolLibraryFile);
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class Gdal method loadSettings.
public static long loadSettings(final Dataset dataset, final Resource resource) {
final Resource settingsFile = resource.newResourceAddExtension("rgobject");
if (settingsFile.exists()) {
try {
final Map<String, Object> settings = Json.toMap(settingsFile);
final String boundingBoxWkt = (String) settings.get("boundingBox");
if (Property.hasValue(boundingBoxWkt)) {
final BoundingBox boundingBox = BoundingBox.newBoundingBox(boundingBoxWkt);
if (!boundingBox.isEmpty()) {
setSpatialReference(dataset, boundingBox.getGeometryFactory());
final double x = boundingBox.getMinX();
final double width = boundingBox.getWidth();
final int imageWidth = dataset.getRasterXSize();
final double y = boundingBox.getMaxY();
final double height = boundingBox.getHeight();
final int imageHeight = dataset.getRasterYSize();
final double[] transform = new double[] { x, width / imageWidth, 0, y, 0, -height / imageHeight };
dataset.SetGeoTransform(transform);
}
}
return settingsFile.getLastModified();
} catch (final Throwable e) {
Logs.error(Gdal.class, "Unable to load:" + settingsFile, e);
return -1;
}
} else {
return -1;
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class GeometryWriter method newGeometryWriter.
@SuppressWarnings("unchecked")
static <GW extends GeometryWriter> GW newGeometryWriter(final Object target, final MapEx properties) {
final Resource resource = Resource.getResource(target);
final GeometryWriterFactory writerFactory = IoFactory.factory(GeometryWriterFactory.class, resource);
return (GW) writerFactory.newGeometryWriter(resource, properties);
}
Aggregations