Using Postgis spatial extension in CDO #29
Replies: 6 comments 1 reply
-
I think that's only possible if we add that type to the literals of the
And presumingly you'll need dedicated |
Beta Was this translation helpful? Give feedback.
-
Hi Eike, Thanks for your quick reply. I've implemented the GEOMETRY type, but struggling to implement the associated type mapping. GeometryTypeFactory geometryType = new GeometryTypeFactory();
container.registerFactory(geometryType); But this doesn't seem to do anything as far as I can see. Can you explain how this factory should work? TypeMappingRegistry typeMappingRegistry = (TypeMappingRegistry) org.eclipse.emf.cdo.server.db.mapping.ITypeMapping.Registry.INSTANCE;
typeMappingRegistry.registerTypeMapping(TypeMappingUtil.createDescriptor(GeometryTypeFactory.TYPE, GesdlPackage.Literals.GEOMETRY, DBType.GEOMETRY)); This type is successfully registered, but it can't use the type mapping because the following code does not work for my type in private ITypeMapping.Descriptor getMappingByType(EStructuralFeature feature, DBType dbType)
{
// First try: lookup specific mapping for the immediate type.
ITypeMapping.Descriptor descriptor = typeMappingByTypes.get(Pair.create(feature.getEType(), dbType));
if (descriptor == null)
{
// Second try: lookup general mapping
descriptor = typeMappingByTypes.get(Pair.create(getEType(feature), dbType));
if (descriptor == null)
{
// Lookup failed. Give up
return null;
}
}
return descriptor;
} It utilized Pair() to look for the type in the registry (first lookup), but my object instance is different somehow. If I debug the code the registered type is:
And the input Pair is:
As the registry is a HashMap, both hashes are different due to the different instances and therefore the type cannot be found. Any idea how to solve this? |
Beta Was this translation helpful? Give feedback.
-
Hi Ewoud, I'm so sorry; this slipped through my fingers somehow! |
Beta Was this translation helpful? Give feedback.
-
Reading your most recent post again, I wonder how exactly you end up with two physical instances of the same logical EDataType. That doesn't sound right in the first place. Could you provide me with a small executable project that demos your registration and lookup process? |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. typeMappingRegistry.registerTypeMapping(TypeMappingUtil.createDescriptor(GeometryTypeFactory.TYPE, GesdlPackage.Literals.GEOMETRY, DBType.GEOMETRY));
|
Beta Was this translation helpful? Give feedback.
-
I guess that the problem is not so much related to Postgres. So would it be possible for you to provide a an independent project with a very simple datatype? I notice that the following custom EDataTypes are included in CDO's test models:
The "CustomType" was easy to search in CDO's test case sources. There is |
Beta Was this translation helpful? Give feedback.
-
We've been running CDO in production for several years with a postgres backend and want to make use of the spatial extension that Postgis offers to store our geographical information in our ecore model. This would for example allow us to query and view only the objects that are in a certain viewport.
Postgis offers a few extra data types that are added to an existing JDBC Connection (PGConnection), to seamlessly work with geospatial data types in Java and JDBC and adds support for setting data to the GEOMETRY database column type. In my custom EDataType I've mapped that type to the GEOMETRY type using the columnType CDO annotation.
The problem now is that GEOMETRY is not a supported DB type in CDO.
How could I add support for this type in CDO?
Stacktrace:
Beta Was this translation helpful? Give feedback.
All reactions