Can Ortus ORM Extension support spatial column format?
best asked over on their forum https://community.ortussolutions.com/
Hey @gaia-jyh ,
The extension does not currently support or work with hibernate-spatial in any way. I wouldnât be opposed to adding this, though I have little experience with hibernate-spatial so Iâm not clear on what you need. Would you mind posting more details about your use case and example code?
One other note is that Iâd prefer to add hibernate-spatial via a separate extension, to mimic Hibernateâs own organization and keep the core ORM extension nice and lightweight.
Hi @michaelborn_me,
Thank you for your response. Iâm interested in using spatial data with the Ortus ORM Extension, specifically with support for GeoJSON or WKT formats.
In my use case, I have a PoliceStation.cfc
component with several properties, including a geometry_4326
property where Iâd like to store spatial data.
how to use EntityNewăEntitySave ?
data in postgis
CREATE TABLE PoliceStation(
ogc_fid SERIAL PRIMARY KEY,
tid VARCHAR(255),
road_name VARCHAR(255),
geometry_4326 geometry(Geometry, 4326)
);
PoliceStation.cfc
component persistent="true"{
property name="ogc_fid" fieldtype="id" generator="increment";
property name="tid" fieldtype="Column" type="string" ;
property name="road_name" fieldtype="Column" type="string" ;
property name="geometry_4326" formula="ST_AsText(geometry_4326)" fieldtype="Column" type="string" ;
}
use sql
INSERT INTO locations (tid,road_name, geometry_4326)
VALUES ('1','Sample Location', ST_GeomFromText('POINT(-97.0533395929335 35.52863966771345)'));
use orm
// Create a new instance of the PoliceStation entity
var newPoliceStation = EntityNew("PoliceStation");
// Set the property values for the new entity
newPoliceStation.setTid("1");
newPoliceStation.setRoad_name("Sample Location");
newPoliceStation.setGeometry_4326("POINT(-97.0533395929335 35.52863966771345)");
// Save the entity to the database
EntitySave(newPoliceStation);
Ok, thatâs a good start for seeing what you want to do. Iâll add this to our issue tracker so you can keep up with whatâs going on.
As far as your question⌠You might be able to get this working through heavy use of formula
properties, per your example. If not, thereâs not much I can do short of implementing hibernate-spatial support⌠since, as I said, this is not currently supported.
I wrote this up here, so it wonât get lost in the shuffle. I canât promise anything, but I will
certainly research the level of effort required.