File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,6 +136,17 @@ public function attachListeners(SharedEventManagerInterface $sharedEventManager)
136136 'api.hydrate.post ' ,
137137 [$ this , 'saveGeometryData ' ]
138138 );
139+ // TODO Fix spatial storage with srid.
140+ $ sharedEventManager ->attach (
141+ $ adapter ,
142+ 'api.create.post ' ,
143+ [$ this , 'fixSridInDatabase ' ]
144+ );
145+ $ sharedEventManager ->attach (
146+ $ adapter ,
147+ 'api.update.post ' ,
148+ [$ this , 'fixSridInDatabase ' ]
149+ );
139150 }
140151
141152 $ sharedEventManager ->attach (
@@ -817,6 +828,23 @@ public function saveGeometryData(Event $event): void
817828 unset($ existingDataValues );
818829 }
819830
831+ /**
832+ * @todo Remove the fix of srid in geographic table after save (check dependency?).
833+ */
834+ public function fixSridInDatabase (Event $ event )
835+ {
836+ $ services = $ this ->getServiceLocator ();
837+ /** @var \Doctrine\DBAL\Connection $connection */
838+ $ connection = $ services ->get ('Omeka\Connection ' );
839+ $ srid = (int ) $ services ->get ('Omeka\Settings ' )->get ('datatypegeometry_locate_srid ' , Geography::DEFAULT_SRID );
840+ $ sql = <<<SQL
841+ UPDATE `data_type_geography`
842+ SET `value` = ST_SRID(`value`, $ srid)
843+ WHERE ST_SRID(`value`) != $ srid;
844+ SQL ;
845+ $ connection ->executeStatement ($ sql );
846+ }
847+
820848 /**
821849 * Get all data types added by this module.
822850 *
You can’t perform that action at this time.
0 commit comments