문제

I have captured four points(coordinate) of a plot using a gps device.

Point 1:- lat- 27.54798833 long- 80.16397166
Point 2:- lat 27.547766, long- 80.16450166
point 3:- lat 27.548131, long- 80.164701
point 4:- ---

now I want to save these coordinate in oracle database which save it as an polygon.

Thanks

도움이 되었습니까?

해결책

If you're intending to use Oracle Spatial for storage or processing of polygons, then you'll need to store the data as an SDO_GEOMETRY object. Here's a quick example:

CREATE TABLE my_polygons (
  id INTEGER
, polygon sdo_geometry
)
/

INSERT INTO my_polygons (
  id
, polygon
)
VALUES (
  1
, sdo_geometry (
    2003 -- 2D Polygon
  , 4326 -- WGS84, the typical GPS coordinate system
  , NULL -- sdo_point_type, should be NULL if sdo_ordinate_array specified
  , sdo_elem_info_array(
      1    -- First ordinate position within ordinate array
    , 1003 -- Exterior polygon
    , 1    -- All polygon points are specified in the ordinate array
    )
  , sdo_ordinate_array(
      80.16397166, 27.54798833,
    , 80.16450166, 27.547766,
    , 80.164701, 27.548131,
    , 80.16397166, 27.54798833
    )
  )
)
/

There's far more information about the different flags on the object type here: http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/sdo_objrelschema.htm

Key things to note:

  1. What is your source coordinate system? You state GPS - is it WGS84 (Oracle SRID = 4326)? Your GPS device will tell you. You can look up the Oracle SRID for this in the table MDSYS.SDO_COORD_REF_SYS
  2. Make sure your coordinates complete a full polygon (i.e. loop back around to the starting point).
  3. Your coordinates for a polygon's external boundary should be ordered anticlockwise.
  4. You can call the method st_isvalid() on a geometry object to quickly test whether it is valid or not. You should ensure geometries are valid before presenting them to any other software.

다른 팁

Create a table for a Polygon storing the Polygon details (PolygonId).

Now create another table Coordinates and for the above PolygonID store the point locatins such as.

 Polygoind Id     Longitude          Latitude

With this if you polygon is having n number or coordinates than also you can store it.And the details can easily be fetched from coordinates table.

One slight correction to Ben's fine answer ...

Oracle Spatial (like pretty much all other geometry encoding systems) stores coordinates in X,Y order, which means that geodetic (lat/long) coordinates must be stored as long, lat - not as lat, long.

So just change the answer to:

, sdo_ordinate_array( 80.16397166, 27.54798833 , 80.16450166, 27.547766 , 80.164701, 27.548131 , 80.16397166, 27.54798833 )

For the purists: the EPSG coordinate system 4326 (WGS84 aka "GPS" coordinates) actually specifies the ordering of coordinates as lat/long, but I know of no implementation that uses anything else but long/lat.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top