SlideShare una empresa de Scribd logo
1 de 83
Implementation a Geospatial Database
     using OGC Simple Feature
             ดร. ไพศาล สันติธรรมนนท
      คณะวิศวกรรมศาสตร จุฬาลงกรณมหาวิทยาลัย
     Email: phisan_chula@yahoo.com

                   ผศ.ดร.ไพศาล สันติธรรมนนท    1
Open Geospatial Consortium
• หนวยงานความรวมมือดานกําหนดมาตรฐานทางภูมิสารสนเทศให
  ทํางานรวมกัน (Interoperability) และแลกเปลี่ยนขอมูลกัน
  ได (Data Sharing)
• ผลผลิตที่ได บอยครั้งพัฒนาไปสูมาตรฐาน นานาชาติ ISO




                       ผศ.ดร.ไพศาล สันติธรรมนนท        2
ผศ.ดร.ไพศาล สันติธรรมนนท   3
OGC Simple Feature Spec.
    Version 1.2 Date: 2006-10-05
• OpenGIS® Implementation Specification
  for Geographic Information - Simple feature
  access - Part 1: Common Architecture
• OpenGIS® Implementation Specification
  for Geographic Information - Simple feature
  access - Part 2: SQL option
•    ISO 19125:2004

                  ผศ.ดร.ไพศาล สันติธรรมนนท   4
ผศ.ดร.ไพศาล สันติธรรมนนท   5
OpenGIS Simple Feature Access
• OpenGIS Simple Feature Access (SFA)
  ISO 19125
• บรรยาย Simple Feature Geometry เปน
  Distributed Computing Platform
• ใช UML ในการบรรยายแบบจําลอง



                ผศ.ดร.ไพศาล สันติธรรมนนท   6
OGC Simple Feature: SQL option
• กําหนด SQL schema เพื่อรองรับการจัดเก็บ การเรียกคืน
  การสืบคนคืน และการปรับปรุง ขอมูลปริภูมิ
• พัฒนาบนพื้นฐาน Simple Geometry โดยการใช the
  SQL Call Level Interface (SQL/CLI)
  (ISO/IEC 9075-3:2003).



                      ผศ.ดร.ไพศาล สันติธรรมนนท         7
แบบจํ า ลองวัต ถุข อ มูล ปริภู มิ
         แบบโอจี ซี
        The Model
  Geospatial Data Object
   according to the OGC



            ผศ.ดร.ไพศาล สันติธรรมนนท   8
OGC Simple Feature
               Geometry Object
•   กํ า หนดมาตรฐานโครงสรา งฐานข อ มูล ปริภูมิ
    และวิธีการประมวลผล
•   แบบจํ า ลองเชิ ง วัต ถุ OGC Geometry Object
    Model
•   รูปแบบการจัดเก็บวัตถุเรขาคณิต ข อ มูล ตั วอั กขระ
    Well-Known Text Format (WKT) และ
    รูปแบบข อ มูล ไบนารี Well-Known Binary
    Format (WKB)
                         ผศ.ดร.ไพศาล สันติธรรมนนท       9
ชั้ นของเรขาคณิ ต (Geometry
     Class Hierachy)




          ผศ.ดร.ไพศาล สันติธรรมนนท   10
แบบจํ า ลองเชิ ง วัต ถุ OGC Object
                       Model
•   จุ ด และกลุ มของจุ ด Point/ MultiPoint
•   เสนโค ง และกลุ มเสนโค ง Curve /
    MultiCurve
•   เสนสตริง ส เสน และ รูปปด LineString, Line,
    LinearRing กลุ มเสนสตริง ส MultiLineString
•   พื้ นผิ ว Surface
•   กลุ มพื้ นผิ วและกลุ มรูปหลายเหลี่ ย ม
    MultiSurfac/ MultiPolygon
                     ผศ.ดร.ไพศาล สันติธรรมนนท   11
ผศ.ดร.ไพศาล สันติธรรมนนท   12
ฟงกชันภายในวัตถุ




    ผศ.ดร.ไพศาล สันติธรรมนนท   13
Geometry Dimension
•   A dimension of –1, 0, 1, or 2:
•   –1 for an empty geometry.
•   0 เรขาคณิตไมมีความยาว ไมมีพื้นที่
•   1 เรขาคณิตมีความยาว และพื้นที่เปนศูนย
•   2 เรขาคณิตมีความยาว และพื้นที่



                          ผศ.ดร.ไพศาล สันติธรรมนนท   14
วัตถุปริภมิ (Spatial Object)
                 ู
• การจัดเก็บขอมูลปริภูมิใน SF เรียกวา Spatial Object
• รูปแบบมีทั้ง Well-Know Text (WKT) หรือ Well-
  Known Binary (WKB)




                      ผศ.ดร.ไพศาล สันติธรรมนนท      15
Well-Known Text Format
                     (WKT)
•   การแสดงข อ มูล เรขาคณิ ต ด วยอักขระ (WKT
    Geometry)
•   การจั ด เก็บและแลกเปลี่ ย นใช รหัสแอสกี
•   การจั ด เก็บและเรีย กใช อา นเข า ใจได ง า ย
•   การแสดงผลทํ า ได โดยตรง
•   เมื่อ คอมพิ วเตอรเ รีย กใช ต อ งมีการแปลง

                        ผศ.ดร.ไพศาล สันติธรรมนนท      16
ตัวอยาง WKT
•   POINT(0 0)

•   LINESTRING(0 0,1 1,1 2)

•   POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))

•   MULTIPOINT(0 0,1 2)

•   MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))

•   MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2
    -2,-2 -1,-1 -1)))

•   GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4)))


                                 ผศ.ดร.ไพศาล สันติธรรมนนท                    17
Well-Known Binary Format
                     (WKB)
•   การแสดงข อ มูล เรขาคณิ ต ด วยไบนารี (WKB
    Geometry)
•   การจั ด เก็บและแลกเปลี่ ย นใช รหัสไบนารี
•   การจั ด เก็บ ประหยั ด และการประมวลผล
    รวดเร็ว
•   เมื่อ ต องการแสดงผลต อ งมีการแปลง

                     ผศ.ดร.ไพศาล สันติธรรมนนท   18
WKB Representation




      ผศ.ดร.ไพศาล สันติธรรมนนท   19
ตัวอยาง WKB
• POINT(1 1) ประกอบดวย 21 bytes แตละไบตแสดงดวย hex digit 2 ตัว

• 0101000000000000000000F03F000000000000F03F

•   รหัสตําแหนงตางๆ แสดง:
•   Byte order : 01
•   WKB type : 01000000
•   X : 000000000000F03F
•   Y : 000000000000F03F


                           ผศ.ดร.ไพศาล สันติธรรมนนท             20
ตัวอยาง WKB
• LINESTRING(1 1, 2 2) ประกอบดวย 41 ไบต:
• 0102000000000000000000F03F000000000000F03F0000
  0000000000400000000000000040

•   Byte order : 01
•   WKB type : 02000000 LINESTRING
•   # points : 02000000 2 points
•   X : 000000000000F03F point #1
•   Y : 000000000000F03F
•   X : 0000000000000040 point #2
•   Y : 0000000000000040

                      ผศ.ดร.ไพศาล สันติธรรมนนท   21
WKB และ WKT
• ไมเสียเวลาแปลงรหัส                     •     การอานเขาตองแปลรหัส
• ใชหนวยความจํานอยกวา                 •     ใชหนวยความจํามากกวา
• แสดงผลในรูปไบนารีโดยตรง                 •     อานเขาใจงาย ไดทันที
  ไมได ตองแสดงในรูป เลขฐานสิบ          •     แนะนํา: ใชระหวางกําลังพัฒนา
  หก (hex) หรือใชฟงกชันแปลง
  ใหเปน ASCII
• แนะนํา: ใชเมื่อทํา
  production service

                           ผศ.ดร.ไพศาล สันติธรรมนนท                            22
ตัวอยางการเขารหัส
• select GeomFromText('POINT(10 20)') default
  SRID เปน -1
• quot;010100000000000000000024400000000000003
  440“

• select SetSRID(GeomFromText('POINT(10
  20)'),4326)
• quot;0101000020E6100000000000000000244000000
  00000003440quot;
                 ผศ.ดร.ไพศาล สันติธรรมนนท   23
Class Point / Class MultiPoint




           ผศ.ดร.ไพศาล สันติธรรมนนท   24
Class LineString /
Class MultiLineString




       ผศ.ดร.ไพศาล สันติธรรมนนท   25
Class Polygons / Class MultiPolygon




              ผศ.ดร.ไพศาล สันติธรรมนนท   26
WKT สําหรับ Spatial Reference
           System




           ผศ.ดร.ไพศาล สันติธรรมนนท   27
WKT สําหรับ SRS
• ใชกําหนด รูปแบบการฉายและพื้นหลักฐาน
  กํากับวัตถุเรขาคณิตโอจีซี
• การสราง เชน ใช epsg_tr / FWTools




                     ผศ.ดร.ไพศาล สันติธรรมนนท   28
EPSG:4326
• C:Program FilesFWTools2.2.0>epsg_tr 4326
• GEOGCS[quot;WGS 84quot;,
•   DATUM[quot;WGS_1984quot;,
•      SPHEROID[quot;WGS 84quot;,6378137,298.257223563,
•        AUTHORITY[quot;EPSGquot;,quot;7030quot;]],
•      AUTHORITY[quot;EPSGquot;,quot;6326quot;]],
•   PRIMEM[quot;Greenwichquot;,0,
•      AUTHORITY[quot;EPSGquot;,quot;8901quot;]],
•   UNIT[quot;degreequot;,0.01745329251994328,
•      AUTHORITY[quot;EPSGquot;,quot;9122quot;]],
•   AUTHORITY[quot;EPSGquot;,quot;4326quot;]]
                    ผศ.ดร.ไพศาล สันติธรรมนนท     29
EPSG:32647
•   C:Program FilesFWTools2.2.0>epsg_tr 32647
•   PROJCS[quot;WGS 84 / UTM zone 47Nquot;,
•     GEOGCS[quot;WGS 84quot;,
•        DATUM[quot;WGS_1984quot;,
•          SPHEROID[quot;WGS 84quot;,6378137,298.257223563,
•            AUTHORITY[quot;EPSGquot;,quot;7030quot;]],
•          AUTHORITY[quot;EPSGquot;,quot;6326quot;]],
•        PRIMEM[quot;Greenwichquot;,0,
•          AUTHORITY[quot;EPSGquot;,quot;8901quot;]],
•        UNIT[quot;degreequot;,0.01745329251994328,
•          AUTHORITY[quot;EPSGquot;,quot;9122quot;]],
•        AUTHORITY[quot;EPSGquot;,quot;4326quot;]],
•     UNIT[quot;metrequot;,1,
•        AUTHORITY[quot;EPSGquot;,quot;9001quot;]],
•     PROJECTION[quot;Transverse_Mercatorquot;],
•     PARAMETER[quot;latitude_of_originquot;,0],
•     PARAMETER[quot;central_meridianquot;,99],
•     PARAMETER[quot;scale_factorquot;,0.9996],
•     PARAMETER[quot;false_eastingquot;,500000],
•     PARAMETER[quot;false_northingquot;,0],
•     AUTHORITY[quot;EPSGquot;,quot;32647quot;]]



                                        ผศ.ดร.ไพศาล สันติธรรมนนท   30
SQL Simple Feature
 Database Structure




      ผศ.ดร.ไพศาล สันติธรรมนนท   31
โครงสรางแบบจําลอง Simple Feature




            ผศ.ดร.ไพศาล สันติธรรมนนท   32
SQL/MM
• The SQL/MM ST_Dimension, ST_GeometryType,
  ST_AsText, ST_AsBinary, ST_SRID, ST_IsEmpty,
  ST_IsSimple, ST_Boundary, and ST_Envelop, SQL/MM
  ST_Equals, ST_Disjoint, ST_Intersects, ST_Touches,
  ST_Crosses, ST_Within, ST_Contains, ST_Overlaps and
  ST_Relate
   – routines shall be supported to test named spatial relationships
     between two geometric objects.
• The SQL/MM ST_Distance
   – supported to calculate the distance between two geometric objects.
• ST_Intersection, ST_Difference, ST_Union,
  ST_SymDifference, ST_Buffer, and ST_ConvexHull

                            ผศ.ดร.ไพศาล สันติธรรมนนท                  33
ผศ.ดร.ไพศาล สันติธรรมนนท   34
ผศ.ดร.ไพศาล สันติธรรมนนท   35
การสรางวัตถุ
OGC Geometry Object Creation




           ผศ.ดร.ไพศาล สันติธรรมนนท   36
GeomFromText(wkt[,srid]), or
      GeometryFromText(wkt[,srid])
•   GeomCollFromText(wkt[,srid]), or GeometryCollectionFromText(wkt[,srid])

•   PointFromText(wkt[,srid])

•   LineFromText(wkt[,srid]), or LineStringFromText(wkt[,srid])

•   MLineFromText(wkt[,srid]), or MultiLineStringFromText(wkt[,srid])

•   MPointFromText(wkt[,srid]), or MultiPointFromText(wkt[,srid])

•   MPolyFromText(wkt[,srid]), or MultiPolygonFromText(wkt[,srid])

•   PolyFromText(wkt[,srid]), or PolygonFromText(wkt[,srid])



                                ผศ.ดร.ไพศาล สันติธรรมนนท                 37
ฟงกชัน วัตถุเรขาคณิต ทั่วไป
•   Dimension(geom)
     – The result can be –1, 0, 1, or 2. The meaning of these values is given in Section 2.2
•   Envelope(geom)
     – Returns the Minimum Bounding Rectangle (MBR) for the geometry value geom.
•   GeometryType(geom)
     – Returns as a string the name of the geometry type of which the geometry instance
       geom is a member.
•   IsEmpty(geom)
     Returns 1 if the geometry value geom is the empty geometry, 0 if it is not empty, or
        NULL if the argument is not a geometry.
•   IsSimple(geom)
     Returns 1 ไมมีสิ่งผิดปรกติ เชน เสนตัดกันเอง เสนชิดกัน
     Returns 0 if the argument is not simple,
     Retruns NULL if the argument is not a geometry.
•   SRID(geom)
     Spatial Reference System ID ชนิดการฉายแผนที่และพื้นหลักฐาน

                                         ผศ.ดร.ไพศาล สันติธรรมนนท                          38
ฟงกชันแปลงรหัส BLOB WKT/WKB
• AsBinary(geom)
  Converts a value in internal BLOB
  geometry format to its WKB representation
  and returns the binary result.
• AsText(geom)
  Converts a value in internal BLOB
  geometry format to its WKT representation
  and returns the string result.
                 ผศ.ดร.ไพศาล สันติธรรมนนท   39
Function หรือ Methods
• แบบจําลอง OGC Simple Feature อธิบายดวย UML
• แตละ Object สัมพันธเปนไปตาม hierarchy
• แตละ Object สามารถทําอะไรไดบาง อธิบายดวย methods
  หรือ functions




                      ผศ.ดร.ไพศาล สันติธรรมนนท      40
ผศ.ดร.ไพศาล สันติธรรมนนท   41
ผศ.ดร.ไพศาล สันติธรรมนนท   42
ผศ.ดร.ไพศาล สันติธรรมนนท   43
ผศ.ดร.ไพศาล สันติธรรมนนท   44
ผศ.ดร.ไพศาล สันติธรรมนนท   45
ผศ.ดร.ไพศาล สันติธรรมนนท   46
ผศ.ดร.ไพศาล สันติธรรมนนท   47
ผศ.ดร.ไพศาล สันติธรรมนนท   48
ความสัมพันธปริภมิของวัตถุ
                ู
 Spatial Relations




        ผศ.ดร.ไพศาล สันติธรรมนนท   49
ตัวอยางความสัมพันธของ รูปปด กับ รูปปด




     เชน             เชน
พื้นทีน้ําทวม
      ่          เขตการปกครอง
                      ผศ.ดร.ไพศาล สันติธรรมนนท   50
การกําหนดขอความบรรยายบนแผนที่
      Annotation Text
    เริ่มใช SF SQL version 1.3




            ผศ.ดร.ไพศาล สันติธรรมนนท   51
Annotation Text
• ใชแสดงขอมูลขาวสาร ตรงตําแหนงที่เกิดขึ้น หรือ ใกลเคียงที่
  เหมาะสม
• ใชแสดงขอความ ขอมูลเฉพาะกิจ (ad-hoc)
• ขึ้นอยูกับ client ที่ใชแสดงแผนที่




                           ผศ.ดร.ไพศาล สันติธรรมนนท              52
ผศ.ดร.ไพศาล สันติธรรมนนท   53
การใช ง าน PostGIS



      ผศ.ดร.ไพศาล สันติธรรมนนท   54
PostgreSQL / PostGIS
• RDMS ประสิทธิภาพสูงรองรับขอมูลขนาดใหญมาก
• วิ่งบนไดเกือบทุกระบบโดยเฉพาะ Linux และ MS
  Window
• รองรับ ACID, foreign keys, joins, views,
  triggers และ store procedures
• มีระบบ Backup, Replication, Fail-over
• สามารถจัดเก็บขอมูลเรขาคณิต โดยอาศัย PostGIS
                     ผศ.ดร.ไพศาล สันติธรรมนนท   55
PostgreSQL
• ปจจุบัน release 8.3
• มี GUI (pgAdmin III) ชวยบริหารจัดการระบบ
• PostGIS version 1.2.x เปนสวนหนึ่งในชุดซอฟตแวร




                     ผศ.ดร.ไพศาล สันติธรรมนนท        56
โครงสราง SF




                              the_geom,
                              geom

  ผศ.ดร.ไพศาล สันติธรรมนนท
                              wkb_geometry
                                             57
ข อ คิ ด คํ า นึง ในการเลื อกใช ซ อฟต แ วร
 รหัสเปด หรือ ซอฟต แ วรเ ชิ ง พาณิ ช ย
•   ปจ จั ย ด า นแมข า ย
     –   ความพรอ มของที มพั ฒ นาและดู แ ลรักษาระบบ
     –   จํ า นวนแมข า ย และผู ใช
•   ปจ จั ย ตั วข อ มูล
     –   ปริมาณข อ มูล มากหรือ นอ ย
     –   อยู ในรูป บนกระดาษหรือ Hardcopy อยู ในรูป
         แฟ มข อ มูล ดิ จิ ทั ล อยู รปแบบแฟ มข อ มูล GIS อยู
                                        ู
         ในรูปแบบฐานข อ มูล GIS
                             ผศ.ดร.ไพศาล สันติธรรมนนท               58
การเชื่อมตอตาราง SF กับ Attribute ภายนอก

• ขอมูล SF สําหรับแปลงที่ดิน the_geom จัดเก็บอยูในตาราง
  “parcel” พรอมเลขแปลงที่ดิน attribute “id”
• แตละแปลงที่ดินมีขอมูลเพิ่มเติมปรากฏในตาราง “owner” และมีเลข
                    
  แปลงที่ดิน “id” กํากับเชนกัน
• การเชื่อมตอใช LEFT JOIN โดยการสรางตารางใหม parceljoin
  ขึ้นมา ตารางใหมมีคอลัมนชื่อ id, ownername, the_geom
   CREATE TABLE parceljoin AS ( SELECT parcel.id as id,
     owner.ownername as ownername, parcel.the_geom as
     the_geom FROM parcel LEFT JOIN owners ON owner.id
      = parcel.id )

                         ผศ.ดร.ไพศาล สันติธรรมนนท               59
การเชื่ อ มต อ UMN MapServer
                          (mapfile)
• …. รายละเอี ย ดอื่ นๆ …รวมทั้ ง OWS/WMS/WFS
•   LAYER
•   CONNECTIONTYPE postgis
•   NAME quot;widehighwaysquot;
•   # Connect to a remote spatial database
•   CONNECTION quot;user=dbuser dbname=gisdatabase host=bigserverquot;
•   # Get the lines from the ’geom’ column of the ’roads’ table
•   DATA quot;geom from roadsquot;
•   STATUS ON
•   TYPE LINE
•   CLASS
•   COLOR 0 0 0
•   END
•   END
                             ผศ.ดร.ไพศาล สันติธรรมนนท
• … ยั ง มีต อ …..
                                                                  60
ข อ คิ ด คํ า นึง ในการเลื อกใช
                  OGC Map Service
•   เราต องการใช ง าน Geoinformation Service
    แบบใดบา ง
    –   เรีย กดู แผนที่ แ ละข อ มูล WMS
    –   เรีย กดู ข อ มูล พรอ มการวิเ คราะห
           WMS/WFS+SLD+FE
    –   แกไขปรับปรุง ข อ มูล เปนครัง คราว
                                      ้                 GIS-
        Editor     replace GIS data
    –   แกไขปรับปรุง ข อ มูล ผ า นเครือ ข า ย        WFS/
        WFS-T
                            ผศ.ดร.ไพศาล สันติธรรมนนท           61
การสรางตารางขอมูล GIS
• การเตรียมตาราง gtest ประกอบดวยฟลด ID และ Name
• นําตาราง gtest ไปสัมพันธกับคอลัมนเรขาคณิต (GIS)
• ฟลดของ GIS ชื่อ ‘geom’




                        ผศ.ดร.ไพศาล สันติธรรมนนท     62
การนําเขาขอมูลและเรียกดู




        ผศ.ดร.ไพศาล สันติธรรมนนท   63
การสืบคนคืน




 ผศ.ดร.ไพศาล สันติธรรมนนท   64
ตัวอยาง Query




   ผศ.ดร.ไพศาล สันติธรรมนนท   65
เรียกผาน Client
• pgsql : เปนแบบ command line เรียกดวย SQL
• UDIG
• QGIS




                   ผศ.ดร.ไพศาล สันติธรรมนนท   66
Functions of PostGIS




      ผศ.ดร.ไพศาล สันติธรรมนนท   67
Mgmt. Functions
• AddGeometryColumn
• DropGeometryColumn
• SetSRID




              ผศ.ดร.ไพศาล สันติธรรมนนท   68
Geometry Relationship Func.
•   Distance                   •     Crosses
•   Equal                      •     Within
•   Disjoint                   •     Overlaps
•   Intersect                  •     Contains
•   Touches                    •     Intersects
                               •     Relate



                ผศ.ดร.ไพศาล สันติธรรมนนท         69
Geometry Processing
•   Centroid                        •     Intersection
•   Area                            •     SymDifference
•   Length                          •     Difference
•   PointOnSurface                  •     GeomUnion
•   Boundary
•   Buffer
•   ConvexHull

                     ผศ.ดร.ไพศาล สันติธรรมนนท            70
Geometry Accessors
•   AsText()                    •     IsClosed
•   AsBinary()                  •     IsRing
•   SRID()                      •     NumGeometries
•   Envelop()                   •     NumPoints
•   IsEmpty                     •     Etc..
•   IsSimple



                 ผศ.ดร.ไพศาล สันติธรรมนนท            71
Geometry Constructors
• GeomFromText
• PointFromText
• Etc..




                  ผศ.ดร.ไพศาล สันติธรรมนนท   72
Operators
• A &< B    overlaps to the left
• A &> B   overlaps to the right
• ……




                ผศ.ดร.ไพศาล สันติธรรมนนท   73
การใชงาน PostGIS




     ผศ.ดร.ไพศาล สันติธรรมนนท   74
สถาปต ยกรรม Geospatial
                             RDBMS
   ขอความ-ผลลัพธ       WMS                   WFS             WFS-T
Text/XML/HTML
                  Rendering service                  WFS Server




                               คําสัง SF SQL
                                    ่

                     Geospatial RDBMS Connector
                                 RDBMS
              Geom TableGeom TableGeom Table
                            ผศ.ดร.ไพศาล สันติธรรมนนท              75
                        Simple Feature
             Simple Feature                   Simple Feature
Geospatial RDBMS / FOSS Solution
   ขอความ-ผลลัพธ              WMS                WFS                  WFS-T
                            UMN MapServer
Text/XML/HTML                 GeoServer          GeoServer             GeoServer
Command Level Interface   Rendering service
     CLI/SQL
   pgsql, ogr2ogr           GD, Java JAI



                                    คําสัง SF SQL
                                         ่

                                       PostGIS
                                    PostgreSQL
                      Geom TableGeom TableGeom Table
                                Simple สัFeature
                                  ผศ.ดร.ไพศาล นติธรรมนนท
                     Simple Feature                   Simple Feature         76
การเรียกใชงานโดยตรง
• เรียกผาน console ของ PostgreSQL
• เรียกผาน pglib เชน VB, .net, ASP
• เรียกผาน ODBC ดวยภาษา JAVA




                    ผศ.ดร.ไพศาล สันติธรรมนนท   77
เรียกใชใหปรากฏเปน Layer หนึ่งของ
     WMS / WFS (Read-only)
         ผาน UMN MapServer
• CONNECTIONTYPE POSTGIS
• CONNECTION “user=xxx dbname=yy
  host=zz”




                ผศ.ดร.ไพศาล สันติธรรมนนท   78
เรียกผาน GeoServer
              เพื่อใหรองรับ WFS-T
• ผูใชสามารถ Update ขอมูลได ผาน WFS-Transaction




                     ผศ.ดร.ไพศาล สันติธรรมนนท    79
เอกสารอางอิง




 ผศ.ดร.ไพศาล สันติธรรมนนท   80
เอกสาร
• PostGIS Manual and Reference




                ผศ.ดร.ไพศาล สันติธรรมนนท   81
ผศ.ดร.ไพศาล สันติธรรมนนท   82
ผศ.ดร.ไพศาล สันติธรรมนนท   83

Más contenido relacionado

Último

Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 
FAIL REKOD PENGAJARAN.pptx fail rekod pengajaran
FAIL REKOD PENGAJARAN.pptx fail rekod pengajaranFAIL REKOD PENGAJARAN.pptx fail rekod pengajaran
FAIL REKOD PENGAJARAN.pptx fail rekod pengajaransekolah233
 
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...Eesti Loodusturism
 
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdfمحاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdfKhaled Elbattawy
 
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 
Bahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 

Último (8)

Energy drink .
Energy drink                           .Energy drink                           .
Energy drink .
 
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
 
FAIL REKOD PENGAJARAN.pptx fail rekod pengajaran
FAIL REKOD PENGAJARAN.pptx fail rekod pengajaranFAIL REKOD PENGAJARAN.pptx fail rekod pengajaran
FAIL REKOD PENGAJARAN.pptx fail rekod pengajaran
 
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
 
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdfمحاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
 
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
 
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
 
Bahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 3 By SadurshSharia Mufti Amjad Ali Azmi
 

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Spat Db 2 Simple Feature

  • 1. Implementation a Geospatial Database using OGC Simple Feature ดร. ไพศาล สันติธรรมนนท คณะวิศวกรรมศาสตร จุฬาลงกรณมหาวิทยาลัย Email: phisan_chula@yahoo.com ผศ.ดร.ไพศาล สันติธรรมนนท 1
  • 2. Open Geospatial Consortium • หนวยงานความรวมมือดานกําหนดมาตรฐานทางภูมิสารสนเทศให ทํางานรวมกัน (Interoperability) และแลกเปลี่ยนขอมูลกัน ได (Data Sharing) • ผลผลิตที่ได บอยครั้งพัฒนาไปสูมาตรฐาน นานาชาติ ISO ผศ.ดร.ไพศาล สันติธรรมนนท 2
  • 4. OGC Simple Feature Spec. Version 1.2 Date: 2006-10-05 • OpenGIS® Implementation Specification for Geographic Information - Simple feature access - Part 1: Common Architecture • OpenGIS® Implementation Specification for Geographic Information - Simple feature access - Part 2: SQL option • ISO 19125:2004 ผศ.ดร.ไพศาล สันติธรรมนนท 4
  • 6. OpenGIS Simple Feature Access • OpenGIS Simple Feature Access (SFA) ISO 19125 • บรรยาย Simple Feature Geometry เปน Distributed Computing Platform • ใช UML ในการบรรยายแบบจําลอง ผศ.ดร.ไพศาล สันติธรรมนนท 6
  • 7. OGC Simple Feature: SQL option • กําหนด SQL schema เพื่อรองรับการจัดเก็บ การเรียกคืน การสืบคนคืน และการปรับปรุง ขอมูลปริภูมิ • พัฒนาบนพื้นฐาน Simple Geometry โดยการใช the SQL Call Level Interface (SQL/CLI) (ISO/IEC 9075-3:2003). ผศ.ดร.ไพศาล สันติธรรมนนท 7
  • 8. แบบจํ า ลองวัต ถุข อ มูล ปริภู มิ แบบโอจี ซี The Model Geospatial Data Object according to the OGC ผศ.ดร.ไพศาล สันติธรรมนนท 8
  • 9. OGC Simple Feature Geometry Object • กํ า หนดมาตรฐานโครงสรา งฐานข อ มูล ปริภูมิ และวิธีการประมวลผล • แบบจํ า ลองเชิ ง วัต ถุ OGC Geometry Object Model • รูปแบบการจัดเก็บวัตถุเรขาคณิต ข อ มูล ตั วอั กขระ Well-Known Text Format (WKT) และ รูปแบบข อ มูล ไบนารี Well-Known Binary Format (WKB) ผศ.ดร.ไพศาล สันติธรรมนนท 9
  • 10. ชั้ นของเรขาคณิ ต (Geometry Class Hierachy) ผศ.ดร.ไพศาล สันติธรรมนนท 10
  • 11. แบบจํ า ลองเชิ ง วัต ถุ OGC Object Model • จุ ด และกลุ มของจุ ด Point/ MultiPoint • เสนโค ง และกลุ มเสนโค ง Curve / MultiCurve • เสนสตริง ส เสน และ รูปปด LineString, Line, LinearRing กลุ มเสนสตริง ส MultiLineString • พื้ นผิ ว Surface • กลุ มพื้ นผิ วและกลุ มรูปหลายเหลี่ ย ม MultiSurfac/ MultiPolygon ผศ.ดร.ไพศาล สันติธรรมนนท 11
  • 13. ฟงกชันภายในวัตถุ ผศ.ดร.ไพศาล สันติธรรมนนท 13
  • 14. Geometry Dimension • A dimension of –1, 0, 1, or 2: • –1 for an empty geometry. • 0 เรขาคณิตไมมีความยาว ไมมีพื้นที่ • 1 เรขาคณิตมีความยาว และพื้นที่เปนศูนย • 2 เรขาคณิตมีความยาว และพื้นที่ ผศ.ดร.ไพศาล สันติธรรมนนท 14
  • 15. วัตถุปริภมิ (Spatial Object) ู • การจัดเก็บขอมูลปริภูมิใน SF เรียกวา Spatial Object • รูปแบบมีทั้ง Well-Know Text (WKT) หรือ Well- Known Binary (WKB) ผศ.ดร.ไพศาล สันติธรรมนนท 15
  • 16. Well-Known Text Format (WKT) • การแสดงข อ มูล เรขาคณิ ต ด วยอักขระ (WKT Geometry) • การจั ด เก็บและแลกเปลี่ ย นใช รหัสแอสกี • การจั ด เก็บและเรีย กใช อา นเข า ใจได ง า ย • การแสดงผลทํ า ได โดยตรง • เมื่อ คอมพิ วเตอรเ รีย กใช ต อ งมีการแปลง ผศ.ดร.ไพศาล สันติธรรมนนท 16
  • 17. ตัวอยาง WKT • POINT(0 0) • LINESTRING(0 0,1 1,1 2) • POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1)) • MULTIPOINT(0 0,1 2) • MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)) • MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))) • GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4))) ผศ.ดร.ไพศาล สันติธรรมนนท 17
  • 18. Well-Known Binary Format (WKB) • การแสดงข อ มูล เรขาคณิ ต ด วยไบนารี (WKB Geometry) • การจั ด เก็บและแลกเปลี่ ย นใช รหัสไบนารี • การจั ด เก็บ ประหยั ด และการประมวลผล รวดเร็ว • เมื่อ ต องการแสดงผลต อ งมีการแปลง ผศ.ดร.ไพศาล สันติธรรมนนท 18
  • 19. WKB Representation ผศ.ดร.ไพศาล สันติธรรมนนท 19
  • 20. ตัวอยาง WKB • POINT(1 1) ประกอบดวย 21 bytes แตละไบตแสดงดวย hex digit 2 ตัว • 0101000000000000000000F03F000000000000F03F • รหัสตําแหนงตางๆ แสดง: • Byte order : 01 • WKB type : 01000000 • X : 000000000000F03F • Y : 000000000000F03F ผศ.ดร.ไพศาล สันติธรรมนนท 20
  • 21. ตัวอยาง WKB • LINESTRING(1 1, 2 2) ประกอบดวย 41 ไบต: • 0102000000000000000000F03F000000000000F03F0000 0000000000400000000000000040 • Byte order : 01 • WKB type : 02000000 LINESTRING • # points : 02000000 2 points • X : 000000000000F03F point #1 • Y : 000000000000F03F • X : 0000000000000040 point #2 • Y : 0000000000000040 ผศ.ดร.ไพศาล สันติธรรมนนท 21
  • 22. WKB และ WKT • ไมเสียเวลาแปลงรหัส • การอานเขาตองแปลรหัส • ใชหนวยความจํานอยกวา • ใชหนวยความจํามากกวา • แสดงผลในรูปไบนารีโดยตรง • อานเขาใจงาย ไดทันที ไมได ตองแสดงในรูป เลขฐานสิบ • แนะนํา: ใชระหวางกําลังพัฒนา หก (hex) หรือใชฟงกชันแปลง ใหเปน ASCII • แนะนํา: ใชเมื่อทํา production service ผศ.ดร.ไพศาล สันติธรรมนนท 22
  • 23. ตัวอยางการเขารหัส • select GeomFromText('POINT(10 20)') default SRID เปน -1 • quot;010100000000000000000024400000000000003 440“ • select SetSRID(GeomFromText('POINT(10 20)'),4326) • quot;0101000020E6100000000000000000244000000 00000003440quot; ผศ.ดร.ไพศาล สันติธรรมนนท 23
  • 24. Class Point / Class MultiPoint ผศ.ดร.ไพศาล สันติธรรมนนท 24
  • 25. Class LineString / Class MultiLineString ผศ.ดร.ไพศาล สันติธรรมนนท 25
  • 26. Class Polygons / Class MultiPolygon ผศ.ดร.ไพศาล สันติธรรมนนท 26
  • 27. WKT สําหรับ Spatial Reference System ผศ.ดร.ไพศาล สันติธรรมนนท 27
  • 28. WKT สําหรับ SRS • ใชกําหนด รูปแบบการฉายและพื้นหลักฐาน กํากับวัตถุเรขาคณิตโอจีซี • การสราง เชน ใช epsg_tr / FWTools ผศ.ดร.ไพศาล สันติธรรมนนท 28
  • 29. EPSG:4326 • C:Program FilesFWTools2.2.0>epsg_tr 4326 • GEOGCS[quot;WGS 84quot;, • DATUM[quot;WGS_1984quot;, • SPHEROID[quot;WGS 84quot;,6378137,298.257223563, • AUTHORITY[quot;EPSGquot;,quot;7030quot;]], • AUTHORITY[quot;EPSGquot;,quot;6326quot;]], • PRIMEM[quot;Greenwichquot;,0, • AUTHORITY[quot;EPSGquot;,quot;8901quot;]], • UNIT[quot;degreequot;,0.01745329251994328, • AUTHORITY[quot;EPSGquot;,quot;9122quot;]], • AUTHORITY[quot;EPSGquot;,quot;4326quot;]] ผศ.ดร.ไพศาล สันติธรรมนนท 29
  • 30. EPSG:32647 • C:Program FilesFWTools2.2.0>epsg_tr 32647 • PROJCS[quot;WGS 84 / UTM zone 47Nquot;, • GEOGCS[quot;WGS 84quot;, • DATUM[quot;WGS_1984quot;, • SPHEROID[quot;WGS 84quot;,6378137,298.257223563, • AUTHORITY[quot;EPSGquot;,quot;7030quot;]], • AUTHORITY[quot;EPSGquot;,quot;6326quot;]], • PRIMEM[quot;Greenwichquot;,0, • AUTHORITY[quot;EPSGquot;,quot;8901quot;]], • UNIT[quot;degreequot;,0.01745329251994328, • AUTHORITY[quot;EPSGquot;,quot;9122quot;]], • AUTHORITY[quot;EPSGquot;,quot;4326quot;]], • UNIT[quot;metrequot;,1, • AUTHORITY[quot;EPSGquot;,quot;9001quot;]], • PROJECTION[quot;Transverse_Mercatorquot;], • PARAMETER[quot;latitude_of_originquot;,0], • PARAMETER[quot;central_meridianquot;,99], • PARAMETER[quot;scale_factorquot;,0.9996], • PARAMETER[quot;false_eastingquot;,500000], • PARAMETER[quot;false_northingquot;,0], • AUTHORITY[quot;EPSGquot;,quot;32647quot;]] ผศ.ดร.ไพศาล สันติธรรมนนท 30
  • 31. SQL Simple Feature Database Structure ผศ.ดร.ไพศาล สันติธรรมนนท 31
  • 32. โครงสรางแบบจําลอง Simple Feature ผศ.ดร.ไพศาล สันติธรรมนนท 32
  • 33. SQL/MM • The SQL/MM ST_Dimension, ST_GeometryType, ST_AsText, ST_AsBinary, ST_SRID, ST_IsEmpty, ST_IsSimple, ST_Boundary, and ST_Envelop, SQL/MM ST_Equals, ST_Disjoint, ST_Intersects, ST_Touches, ST_Crosses, ST_Within, ST_Contains, ST_Overlaps and ST_Relate – routines shall be supported to test named spatial relationships between two geometric objects. • The SQL/MM ST_Distance – supported to calculate the distance between two geometric objects. • ST_Intersection, ST_Difference, ST_Union, ST_SymDifference, ST_Buffer, and ST_ConvexHull ผศ.ดร.ไพศาล สันติธรรมนนท 33
  • 36. การสรางวัตถุ OGC Geometry Object Creation ผศ.ดร.ไพศาล สันติธรรมนนท 36
  • 37. GeomFromText(wkt[,srid]), or GeometryFromText(wkt[,srid]) • GeomCollFromText(wkt[,srid]), or GeometryCollectionFromText(wkt[,srid]) • PointFromText(wkt[,srid]) • LineFromText(wkt[,srid]), or LineStringFromText(wkt[,srid]) • MLineFromText(wkt[,srid]), or MultiLineStringFromText(wkt[,srid]) • MPointFromText(wkt[,srid]), or MultiPointFromText(wkt[,srid]) • MPolyFromText(wkt[,srid]), or MultiPolygonFromText(wkt[,srid]) • PolyFromText(wkt[,srid]), or PolygonFromText(wkt[,srid]) ผศ.ดร.ไพศาล สันติธรรมนนท 37
  • 38. ฟงกชัน วัตถุเรขาคณิต ทั่วไป • Dimension(geom) – The result can be –1, 0, 1, or 2. The meaning of these values is given in Section 2.2 • Envelope(geom) – Returns the Minimum Bounding Rectangle (MBR) for the geometry value geom. • GeometryType(geom) – Returns as a string the name of the geometry type of which the geometry instance geom is a member. • IsEmpty(geom) Returns 1 if the geometry value geom is the empty geometry, 0 if it is not empty, or NULL if the argument is not a geometry. • IsSimple(geom) Returns 1 ไมมีสิ่งผิดปรกติ เชน เสนตัดกันเอง เสนชิดกัน Returns 0 if the argument is not simple, Retruns NULL if the argument is not a geometry. • SRID(geom) Spatial Reference System ID ชนิดการฉายแผนที่และพื้นหลักฐาน ผศ.ดร.ไพศาล สันติธรรมนนท 38
  • 39. ฟงกชันแปลงรหัส BLOB WKT/WKB • AsBinary(geom) Converts a value in internal BLOB geometry format to its WKB representation and returns the binary result. • AsText(geom) Converts a value in internal BLOB geometry format to its WKT representation and returns the string result. ผศ.ดร.ไพศาล สันติธรรมนนท 39
  • 40. Function หรือ Methods • แบบจําลอง OGC Simple Feature อธิบายดวย UML • แตละ Object สัมพันธเปนไปตาม hierarchy • แตละ Object สามารถทําอะไรไดบาง อธิบายดวย methods หรือ functions ผศ.ดร.ไพศาล สันติธรรมนนท 40
  • 49. ความสัมพันธปริภมิของวัตถุ ู Spatial Relations ผศ.ดร.ไพศาล สันติธรรมนนท 49
  • 50. ตัวอยางความสัมพันธของ รูปปด กับ รูปปด เชน เชน พื้นทีน้ําทวม ่ เขตการปกครอง ผศ.ดร.ไพศาล สันติธรรมนนท 50
  • 51. การกําหนดขอความบรรยายบนแผนที่ Annotation Text เริ่มใช SF SQL version 1.3 ผศ.ดร.ไพศาล สันติธรรมนนท 51
  • 52. Annotation Text • ใชแสดงขอมูลขาวสาร ตรงตําแหนงที่เกิดขึ้น หรือ ใกลเคียงที่ เหมาะสม • ใชแสดงขอความ ขอมูลเฉพาะกิจ (ad-hoc) • ขึ้นอยูกับ client ที่ใชแสดงแผนที่ ผศ.ดร.ไพศาล สันติธรรมนนท 52
  • 54. การใช ง าน PostGIS ผศ.ดร.ไพศาล สันติธรรมนนท 54
  • 55. PostgreSQL / PostGIS • RDMS ประสิทธิภาพสูงรองรับขอมูลขนาดใหญมาก • วิ่งบนไดเกือบทุกระบบโดยเฉพาะ Linux และ MS Window • รองรับ ACID, foreign keys, joins, views, triggers และ store procedures • มีระบบ Backup, Replication, Fail-over • สามารถจัดเก็บขอมูลเรขาคณิต โดยอาศัย PostGIS ผศ.ดร.ไพศาล สันติธรรมนนท 55
  • 56. PostgreSQL • ปจจุบัน release 8.3 • มี GUI (pgAdmin III) ชวยบริหารจัดการระบบ • PostGIS version 1.2.x เปนสวนหนึ่งในชุดซอฟตแวร ผศ.ดร.ไพศาล สันติธรรมนนท 56
  • 57. โครงสราง SF the_geom, geom ผศ.ดร.ไพศาล สันติธรรมนนท wkb_geometry 57
  • 58. ข อ คิ ด คํ า นึง ในการเลื อกใช ซ อฟต แ วร รหัสเปด หรือ ซอฟต แ วรเ ชิ ง พาณิ ช ย • ปจ จั ย ด า นแมข า ย – ความพรอ มของที มพั ฒ นาและดู แ ลรักษาระบบ – จํ า นวนแมข า ย และผู ใช • ปจ จั ย ตั วข อ มูล – ปริมาณข อ มูล มากหรือ นอ ย – อยู ในรูป บนกระดาษหรือ Hardcopy อยู ในรูป แฟ มข อ มูล ดิ จิ ทั ล อยู รปแบบแฟ มข อ มูล GIS อยู ู ในรูปแบบฐานข อ มูล GIS ผศ.ดร.ไพศาล สันติธรรมนนท 58
  • 59. การเชื่อมตอตาราง SF กับ Attribute ภายนอก • ขอมูล SF สําหรับแปลงที่ดิน the_geom จัดเก็บอยูในตาราง “parcel” พรอมเลขแปลงที่ดิน attribute “id” • แตละแปลงที่ดินมีขอมูลเพิ่มเติมปรากฏในตาราง “owner” และมีเลข  แปลงที่ดิน “id” กํากับเชนกัน • การเชื่อมตอใช LEFT JOIN โดยการสรางตารางใหม parceljoin ขึ้นมา ตารางใหมมีคอลัมนชื่อ id, ownername, the_geom CREATE TABLE parceljoin AS ( SELECT parcel.id as id, owner.ownername as ownername, parcel.the_geom as the_geom FROM parcel LEFT JOIN owners ON owner.id = parcel.id ) ผศ.ดร.ไพศาล สันติธรรมนนท 59
  • 60. การเชื่ อ มต อ UMN MapServer (mapfile) • …. รายละเอี ย ดอื่ นๆ …รวมทั้ ง OWS/WMS/WFS • LAYER • CONNECTIONTYPE postgis • NAME quot;widehighwaysquot; • # Connect to a remote spatial database • CONNECTION quot;user=dbuser dbname=gisdatabase host=bigserverquot; • # Get the lines from the ’geom’ column of the ’roads’ table • DATA quot;geom from roadsquot; • STATUS ON • TYPE LINE • CLASS • COLOR 0 0 0 • END • END ผศ.ดร.ไพศาล สันติธรรมนนท • … ยั ง มีต อ ….. 60
  • 61. ข อ คิ ด คํ า นึง ในการเลื อกใช OGC Map Service • เราต องการใช ง าน Geoinformation Service แบบใดบา ง – เรีย กดู แผนที่ แ ละข อ มูล WMS – เรีย กดู ข อ มูล พรอ มการวิเ คราะห WMS/WFS+SLD+FE – แกไขปรับปรุง ข อ มูล เปนครัง คราว ้ GIS- Editor replace GIS data – แกไขปรับปรุง ข อ มูล ผ า นเครือ ข า ย WFS/ WFS-T ผศ.ดร.ไพศาล สันติธรรมนนท 61
  • 62. การสรางตารางขอมูล GIS • การเตรียมตาราง gtest ประกอบดวยฟลด ID และ Name • นําตาราง gtest ไปสัมพันธกับคอลัมนเรขาคณิต (GIS) • ฟลดของ GIS ชื่อ ‘geom’ ผศ.ดร.ไพศาล สันติธรรมนนท 62
  • 63. การนําเขาขอมูลและเรียกดู ผศ.ดร.ไพศาล สันติธรรมนนท 63
  • 65. ตัวอยาง Query ผศ.ดร.ไพศาล สันติธรรมนนท 65
  • 66. เรียกผาน Client • pgsql : เปนแบบ command line เรียกดวย SQL • UDIG • QGIS ผศ.ดร.ไพศาล สันติธรรมนนท 66
  • 67. Functions of PostGIS ผศ.ดร.ไพศาล สันติธรรมนนท 67
  • 68. Mgmt. Functions • AddGeometryColumn • DropGeometryColumn • SetSRID ผศ.ดร.ไพศาล สันติธรรมนนท 68
  • 69. Geometry Relationship Func. • Distance • Crosses • Equal • Within • Disjoint • Overlaps • Intersect • Contains • Touches • Intersects • Relate ผศ.ดร.ไพศาล สันติธรรมนนท 69
  • 70. Geometry Processing • Centroid • Intersection • Area • SymDifference • Length • Difference • PointOnSurface • GeomUnion • Boundary • Buffer • ConvexHull ผศ.ดร.ไพศาล สันติธรรมนนท 70
  • 71. Geometry Accessors • AsText() • IsClosed • AsBinary() • IsRing • SRID() • NumGeometries • Envelop() • NumPoints • IsEmpty • Etc.. • IsSimple ผศ.ดร.ไพศาล สันติธรรมนนท 71
  • 72. Geometry Constructors • GeomFromText • PointFromText • Etc.. ผศ.ดร.ไพศาล สันติธรรมนนท 72
  • 73. Operators • A &< B overlaps to the left • A &> B overlaps to the right • …… ผศ.ดร.ไพศาล สันติธรรมนนท 73
  • 74. การใชงาน PostGIS ผศ.ดร.ไพศาล สันติธรรมนนท 74
  • 75. สถาปต ยกรรม Geospatial RDBMS ขอความ-ผลลัพธ WMS WFS WFS-T Text/XML/HTML Rendering service WFS Server คําสัง SF SQL ่ Geospatial RDBMS Connector RDBMS Geom TableGeom TableGeom Table ผศ.ดร.ไพศาล สันติธรรมนนท 75 Simple Feature Simple Feature Simple Feature
  • 76. Geospatial RDBMS / FOSS Solution ขอความ-ผลลัพธ WMS WFS WFS-T UMN MapServer Text/XML/HTML GeoServer GeoServer GeoServer Command Level Interface Rendering service CLI/SQL pgsql, ogr2ogr GD, Java JAI คําสัง SF SQL ่ PostGIS PostgreSQL Geom TableGeom TableGeom Table Simple สัFeature ผศ.ดร.ไพศาล นติธรรมนนท Simple Feature Simple Feature 76
  • 77. การเรียกใชงานโดยตรง • เรียกผาน console ของ PostgreSQL • เรียกผาน pglib เชน VB, .net, ASP • เรียกผาน ODBC ดวยภาษา JAVA ผศ.ดร.ไพศาล สันติธรรมนนท 77
  • 78. เรียกใชใหปรากฏเปน Layer หนึ่งของ WMS / WFS (Read-only) ผาน UMN MapServer • CONNECTIONTYPE POSTGIS • CONNECTION “user=xxx dbname=yy host=zz” ผศ.ดร.ไพศาล สันติธรรมนนท 78
  • 79. เรียกผาน GeoServer เพื่อใหรองรับ WFS-T • ผูใชสามารถ Update ขอมูลได ผาน WFS-Transaction ผศ.ดร.ไพศาล สันติธรรมนนท 79
  • 81. เอกสาร • PostGIS Manual and Reference ผศ.ดร.ไพศาล สันติธรรมนนท 81