[postgis-users] [From Oracle Spatial to PostGIS] How to store rectangles?
simon at spatialdbadvisor.com
Sun Apr 26 15:41:51 PDT 2009
> I'm porting an application from Oracle Spatial to PostGIS.
> In particular I've come across this code in an INSERT statment:
> MDSYS.SDO_GEOMETRY(2003,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3) --
> ,MDSYS.SDO_ORDINATE_ARRAY("+topleftlat+", "+topleftlon+",
> "+bottomrightlat+", "+bottomrightlon+")),null)
> I understand this loads a rectangle in 2 points.
> I've written this postGIS code:
> GeomFromText('POLYGON("+topleftlat+" "+topleftlon+" "+bottomrightlat+"
> "+bottomrightlon+"))', -1)
> Obviously it doesn't work yet. Is this the right direction? Is there a way
> to store rectangles in postGIS in a similar fashion?
See the PostGIS manual (I have slightly modified the relevant entry):
UPDATE mytable set bbox = ST_MakeBox2D(ST_MakePoint(bottomrightlon,bottomrightlat), ST_MakePoint(topleftlon, topleftlat))
Note that in PostGIS and Oracle X = Longitude and Y = Latitude
Hope this helps
SpatialDB Advice and Design, Solutions Architecture and Programming,
Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Email: simon at spatialdbadvisor.com
Voice: +61 362 396397
Mobile: +61 418 396391
Longitude: 147.20515 (147° 12' 18" E)
Latitude: -43.01530 (43° 00' 55" S)
More information about the postgis-users