pantone 123 c pro oracle spatial for oracle database 11 … · 2016-10-26 · pro oracle spatial...
TRANSCRIPT
this print for content only—size & color not accurate 7" x 9-1/4" / CASEBOUND / MALLOY(1.625 INCH BULK -- 824 pages -- 50# Thor)
THE EXPERT’S VOICE® IN ORACLE
Ravi Kothuri, Albert Godfrind, and Euro Beinat
ProOracle Spatialfor Oracle Database 11g
The essential guide to developing spatially enabled business applications using Oracle
BOOKS FOR PROFESSIONALS BY PROFESSIONALS®
Pro Oracle Spatial for Oracle Database 11gDear Reader,
This book will provide you with the conceptual knowledge and practical skills to become a professional in spatial information management. It contains all you need to master one of the most powerful tools available for this purpose: Oracle Spatial. The power of Oracle Spatial—the set of spatial technologies for the Oracle database—stems from the fact that you can store, retrieve, analyze, and visualize spatial data just like any other type of data and integrate it into any business application. You can do so by using the same tools and languages with which you are familiar, such as SQL, Java, and XML.
Spatial information is utilized in a variety of applications. Think about how you get travel directions from your GPS, how cables and pipes are maintained, how distribution chains choose the location of their outlets, or how we predict storms and weather. Almost every organization now stores spatial information assets. Pro Oracle Spatial for Oracle Database 11g shows you how to manage and make the most effective use of that information.
The book introduces the concepts of spatial data, the architecture of Oracle Spatial, and the vast set of functions and procedures for managing spatial data. It shows how to create spatial applications, how to integrate the technology into existing applications, and how organizations have already successfully imple-mented spatial solutions. The book provides sample data, examples, and tips so that you can learn, experiment, and find guidance in becoming an expert Oracle Spatial developer. It will allow you to develop exciting applications, be part of large and inspiring projects, and explore the rich world of spatial data. It is our hope that you will find this world as interesting and challenging as we do.
Enjoy!
Ravi Kothuri, Ph.D.; Albert Godfrind; and Euro Beinat, Ph.D.
THE APRESS ROADMAP
BeginningOracle Programming
BeginningPL/SQL
Mastering OracleSQL & SQL*Plus
MasteringOracle PL/SQL
Pro Oracle Spatialfor Oracle Database 11g
Kothuri,Godfrind,
Beinat
CYAN MAGENTA
YELLOW BLACK PANTONE 123 C
Ravi Kothuri
ISBN-13: 978-1-59059-899-3ISBN-10: 1-59059-899-7
9 781590 598993
90000
Shelve in Databases/Oracle
User level: Intermediate–Advanced
www.apress.comSOURCE CODE ONLINE
Companion eBook
See last page for details
on $10 eBook version
Companion eBook Available
Updated forOracle
Database 11g
Updated forOracle
Database 11g
Albert Godfrind
Euro Beinat
Kothuri, Godfrind, and Beinat coauthored
Pro Oracle Spatial (first edition)
ProOracle Spatialfor Oracle Database 11g
www.it-ebooks.info
www.it-ebooks.info
Ravi Kothuri, Albert Godfrind, and Euro Beinat
Pro Oracle Spatial forOracle Database 11g
8997ch00FM.qxt 9/28/07 9:52 AM Page i
www.it-ebooks.info
Pro Oracle Spatial for Oracle Database 11gCopyright © 2007 by Ravi Kothuri, Albert Godfrind, Euro BeinatAll rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,electronic or mechanical, including photocopying, recording, or by any information storage or retrievalsystem, without the prior written permission of the copyright owner and the publisher.
ISBN-13: 978-1-59059-899-3
ISBN-10: 1-59059-899-7
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrenceof a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademarkowner, with no intention of infringement of the trademark.
Lead Editor: Jonathan GennickTechnical Reviewer: Carel-Jan EngelEditorial Board: Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Jason
Gilmore, Kevin Goff, Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh
Project Manager: Kylie JohnstonCopy Editor: Kim WimpsettAssistant Production Director: Kari Brooks-CoponyProduction Editor: Ellie FountainCompositor: Kinetic Publishing Services, LLCProofreader: Linda SeifertIndexer: Broccoli Information ManagementArtist: Kinetic Publishing Services, LLCCover Designer: Kurt KramesManufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], orvisit http://www.springeronline.com.
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley,CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com.
The information in this book is distributed on an “as is” basis, without warranty. Although every precau-tion has been taken in the preparation of this work, neither the author(s) nor Apress shall have anyliability to any person or entity with respect to any loss or damage caused or alleged to be caused directlyor indirectly by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Source Code/Downloadsection.
8997ch00FM.qxt 9/28/07 9:52 AM Page ii
www.it-ebooks.info
Contents at a Glance
About the Authors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Setting Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
PART 1 ■ ■ ■ Overview■CHAPTER 1 Spatial Information Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
■CHAPTER 2 Overview of Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
■CHAPTER 3 Location-Enabling Your Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
PART 2 ■ ■ ■ Basic Spatial■CHAPTER 4 The SDO_GEOMETRY Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
■CHAPTER 5 Loading, Transporting, and Validating Spatial Data. . . . . . . . . . . . . . . . . . . 115
■CHAPTER 6 Geocoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
■CHAPTER 7 Manipulating SDO_GEOMETRY in Application Programs. . . . . . . . . . . . . . 207
PART 3 ■ ■ ■ Spatial and Network Analysis■CHAPTER 8 Spatial Indexes and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
■CHAPTER 9 Geometry Processing Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
■CHAPTER 10 Network Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
■CHAPTER 11 The Routing Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
PART 4 ■ ■ ■ Visualization■CHAPTER 12 Defining Maps Using MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
■CHAPTER 13 Using Maps in Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
iii
8997ch00FM.qxt 9/28/07 9:52 AM Page iii
www.it-ebooks.info
PART 5 ■ ■ ■ Spatial in Applications■CHAPTER 14 Sample Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
■CHAPTER 15 Case Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
■CHAPTER 16 Tips, Common Mistakes, and Common Errors . . . . . . . . . . . . . . . . . . . . . . . 663
PART 6 ■ ■ ■ Appendixes■APPENDIX A Additional Spatial Analysis Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
■APPENDIX B Linear Referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
■APPENDIX C Topology Data Model in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
■APPENDIX D Storing Raster Data in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
■APPENDIX E Three-Dimensional Modeling Using Point Clouds and TINs in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757
8997ch00FM.qxt 9/28/07 9:52 AM Page iv
www.it-ebooks.info
Contents
About the Authors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Setting Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
PART 1 ■ ■ ■ Overview■CHAPTER 1 Spatial Information Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Using Spatial Information in Various Industries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Sources of Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Managing and Analyzing Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Storing Spatial Data in a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Spatial Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Benefits of Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
■CHAPTER 2 Overview of Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Technology and Architecture Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Getting Started with Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Data Model: Storing Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Location-Enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Query and Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Visualizing Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Advanced Spatial Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Oracle Spatial Technology Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Locator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Spatial Option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
What to Expect in an Oracle Spatial Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Installing Oracle Spatial in the Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Upgrades. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Understanding a Spatial Install. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Checking the Version of a Spatial Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36v
8997ch00FM.qxt 9/28/07 9:52 AM Page v
www.it-ebooks.info
■CHAPTER 3 Location-Enabling Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . 37
Adding Location Information to Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Application-Specific Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Geographic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Metadata for Spatial Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Dictionary View for Spatial Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Populating Spatial Metadata for Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . 49Additional Information for Visualization and Network Analysis . . . . . . . . . . 50
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
PART 2 ■ ■ ■ Basic Spatial■CHAPTER 4 The SDO_GEOMETRY Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Types of Spatial Geometries in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Line Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Polygons and Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Solids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Logical Implementation of SDO_GEOMETRY . . . . . . . . . . . . . . . . . . . . . . . . 58Spatial Data in SQL/MM and OGC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
SDO_GEOMETRY Type, Attributes, and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60SDO_GTYPE Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61SDO_SRID Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63SDO_POINT Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72SDO_ELEM_INFO and SDO_ORDINATES Attributes . . . . . . . . . . . . . . . . . . . 74
Simple Two-Dimensional Geometry Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Line String: Connected by Straight Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Line String: Connected by Arcs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79Polygon: Ring (Boundary) Connected by Straight Lines . . . . . . . . . . . . . . . . 80Polygon: Ring (Boundary) Connected by Arcs . . . . . . . . . . . . . . . . . . . . . . . . 82Rectangle Polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82Circle Polygon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Complex Two-Dimensional Geometry Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 84Constructing Complex Geometries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85SDO_ELEM_INFO for Compound Elements. . . . . . . . . . . . . . . . . . . . . . . . . . 86SDO_ELEM_INFO for Voided Polygon Element . . . . . . . . . . . . . . . . . . . . . . . 87Compound Line String Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87Compound Polygon Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Polygon with a Void . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
■CONTENTSvi
8997ch00FM.qxt 9/28/07 9:52 AM Page vi
www.it-ebooks.info
Three-Dimensional Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95Three-Dimensional Points, Lines, and Polygons. . . . . . . . . . . . . . . . . . . . . . 97Composite Surfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Simple Solid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Composite Solid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
■CHAPTER 5 Loading, Transporting, and Validating Spatial Data . . . . . . . . 115
Inserting Data into an SDO_GEOMETRY Column . . . . . . . . . . . . . . . . . . . . . . . . . 116Loading and Converting Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Loading from Text Files Using SQL*Loader . . . . . . . . . . . . . . . . . . . . . . . . . 117Transporting Spatial Data Between Oracle Databases. . . . . . . . . . . . . . . . 120Loading from External Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122Converting Between SDO_GEOMETRY and WKT/WKB. . . . . . . . . . . . . . . . 124Converting SDO_GEOMETRY Data in GML . . . . . . . . . . . . . . . . . . . . . . . . . 124
Extruding a Two-Dimensional Geometry to Three Dimensions . . . . . . . . . . . . . . 129Validating Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Validation Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132Validation Criteria. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Composite Solids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Debugging Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142REMOVE_DUPLICATE_VERTICES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142EXTRACT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143APPEND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146GETNUMELEM, GETNUMVERTICES, and GETVERTICES . . . . . . . . . . . . . . . 147EXTRACT3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147Miscellaneous Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
■CHAPTER 6 Geocoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
What Is Geocoding? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Architecture of the Oracle Geocoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Parsing the Input Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Searching for the Address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Computing the Spatial Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Setting Up the Reference Data for the Geocoder . . . . . . . . . . . . . . . . . . . . . . . . . 156Parameter Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156Data Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
■CONTENTS vii
8997ch00FM.qxt 9/28/07 9:52 AM Page vii
www.it-ebooks.info
Using Geocoder Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158GEOCODE_AS_GEOMETRY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158GEOCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161GEOCODE_ALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Geocoding Using Structured Addresses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182GEOCODE_ADDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182GEOCODE_ADDR_ALL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Reverse Geocoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184REVERSE_GEOCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Geocoding Business Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Adding the Spatial Column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Geocoding the Addresses: The “Naive” Approach . . . . . . . . . . . . . . . . . . . 187Address Verification and Correction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188Automatic Geocoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
The Geocoding Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196Installation and Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Using the Geocoder: XML Queries and Responses. . . . . . . . . . . . . . . . . . . 200
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
■CHAPTER 7 Manipulating SDO_GEOMETRY in Application Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Manipulating Geometries Using PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209VARRAY Manipulation Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Reading and Writing SDO_GEOMETRY Objects . . . . . . . . . . . . . . . . . . . . . 215Creating New Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215Extracting Information from Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . 217Modifying Existing Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Manipulating Geometries in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Using the JGeometry Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Using 3D Geometries: the J3D_Geometry Class . . . . . . . . . . . . . . . . . . . . 229Extracting Elements from 3D Geometries: the
ElementExtractor Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Using Standard Notations: WKT, WKB, GML . . . . . . . . . . . . . . . . . . . . . . . . 232Using ESRI Shapefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
■CONTENTSviii
8997ch00FM.qxt 9/28/07 9:52 AM Page viii
www.it-ebooks.info
PART 3 ■ ■ ■ Spatial and Network Analysis
■CHAPTER 8 Spatial Indexes and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Spatial Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245Inserting Metadata for a Spatial Layer Prior to Indexing . . . . . . . . . . . . . . 246Creating a Spatial Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247Spatial Indexing Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Spatial Index Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Syntax of Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253Semantics of Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254Evaluation of Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
A Closer Look at Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256SDO_WITHIN_DISTANCE Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256SDO_NN Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261Operators for Spatial Interactions (Relationships) . . . . . . . . . . . . . . . . . . . 268Hints for Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Advanced Spatial Index Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287Function-Based Spatial Indexes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287Local Partitioned Spatial Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290Parallel Indexing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293Online Index Rebuilds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294Spatial Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295Three-Dimensional Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
■CHAPTER 9 Geometry Processing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Buffering Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307Relationship Analysis Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
SDO_DISTANCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310SDO_CLOSEST_POINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313RELATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Geometry Combination Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320SDO_INTERSECTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321SDO_UNION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323SDO_DIFFERENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323SDO_XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Geometric Analysis Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326Area, Length, and Volume Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326MBR Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330Miscellaneous Geometric Analysis Functions . . . . . . . . . . . . . . . . . . . . . . . 333
■CONTENTS ix
8997ch00FM.qxt 9/28/07 9:52 AM Page ix
www.it-ebooks.info
Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337Aggregate MBR Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337Other Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
■CHAPTER 10 Network Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
General Network Modeling Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347Examples of Networks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348Oracle Network Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Data Structures: The Network Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351Node Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352Link Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352Path Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353Path Link Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354Network Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Defining Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355“Automatic” Network Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355“Manual” Network Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357Defining Multiple Networks on the Same Tables . . . . . . . . . . . . . . . . . . . . 359Dropping a Network. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363Creating Spatial Indexes on Network Tables. . . . . . . . . . . . . . . . . . . . . . . . 363Getting Information About a Network. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364Verifying Network Connectivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365Example Network. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
Analyzing and Managing Networks Using the Java API . . . . . . . . . . . . . . . . . . . . 370Analyzing Networks: The NetworkManager Class . . . . . . . . . . . . . . . . . . . 370Limiting the Search Space: The SystemConstraint Class . . . . . . . . . . . . . 384Advanced Analysis: Network Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . 385Network Structures: The Network, Node, Link, and Path Classes. . . . . . . 391Creating Networks: The NetworkFactory Class. . . . . . . . . . . . . . . . . . . . . . 394
Debugging Network Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396Analyzing Networks Using the PL/SQL API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Using a Memory Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399Analyzing Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400Creating and Updating Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403Using Network Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
The Network Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412Starting the Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412Using the Loaded Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414Example Data: The Streets of San Francisco . . . . . . . . . . . . . . . . . . . . . . . 415
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
■CONTENTSx
8997ch00FM.qxt 9/28/07 9:52 AM Page x
www.it-ebooks.info
■CHAPTER 11 The Routing Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418Installation and Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422Example Data: The Streets of San Francisco . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424Partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425Using the Router: XML Queries and Responses . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Routing Requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430Routing Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431Pregeocoded Start and End Locations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431Geographic Start and End Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432Batch Routing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
PART 4 ■ ■ ■ Visualization
■CHAPTER 12 Defining Maps Using MapViewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Why Use Maps in Location-Enabled Applications?. . . . . . . . . . . . . . . . . . . . . . . . 437Overview of MapViewer and Oracle Maps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Oracle MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440Oracle Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443Load the Sample Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444Location-Enable the Application Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445Load the Geographical Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445Load Maps, Themes, Style, and Map Cache Definitions
for MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445Define a Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446Install Example Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Configuring MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448Using the Administration Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
Defining Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457Using Map Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Using Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461Using Themes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Using Maps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
■CONTENTS xi
8997ch00FM.qxt 9/28/07 9:52 AM Page xi
www.it-ebooks.info
Defining Map Caches. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491The USER_SDO_CACHED_MAPS View . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491Managing Caches Using the MapViewer Console . . . . . . . . . . . . . . . . . . . 491Creating a New Map Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493Creating Map Caches Using SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495Cache Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498Exporting Cache Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498Purging and Refreshing Cache Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . 498Using External Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
■CHAPTER 13 Using Maps in Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Overview of MapViewer’s APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503XML, Java, JSPs, and PL/SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503JavaScript and Ajax: Oracle Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505Choosing an API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
Anatomy of a Map Request. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507What: The Information That Should Appear on the Map . . . . . . . . . . . . . . 507Where: The Geographical Area to Be Covered by the Map . . . . . . . . . . . . 508How: The Format and Size of the Resulting Map . . . . . . . . . . . . . . . . . . . . 508
Interacting with Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509Controlling the Level of Detail: Zoom In and Zoom Out . . . . . . . . . . . . . . . 509Controlling the Area Shown on the Map: Pan and Recenter . . . . . . . . . . . 509Selecting Features: Identify. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510Choosing the Information to Appear on the Map: Layer Control . . . . . . . . 510
Oracle Maps: The JavaScript API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510Displaying a Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511Interacting with Maps: Zooming and Panning. . . . . . . . . . . . . . . . . . . . . . . 514Adding Map Decorations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515Adding Generic Decorations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515Creating an Overview Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516Rectangular (Marquee) Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517Adding Dynamic Information: Theme-Based FOIs . . . . . . . . . . . . . . . . . . . 519Adding Individual FOIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523Controlling Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524Capturing User Input: Tools and Selectors. . . . . . . . . . . . . . . . . . . . . . . . . . 525Responding to Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Using the Java API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530Map Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530Zooming and Panning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533Theme Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535Style Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540Identification and Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
■CONTENTSxii
8997ch00FM.qxt 9/28/07 9:52 AM Page xii
www.it-ebooks.info
Dynamic Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543Legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543Map Decorations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545Using the Map Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546Discovering Data Sources, Maps, Themes . . . . . . . . . . . . . . . . . . . . . . . . . 547Using JSP Tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Using the XML API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552Simple Map Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553Adding Themes to a Base Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555Using Multiple Data Sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556Constructing a Map from Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557Dynamic Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558Dynamic Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561Legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563The XML Map Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Using the PL/SQL API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566Installing the API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566A Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Using the Administrative API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568Browsing Map Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568Managing the MapViewer Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Restarting MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
Web Map Service (OGC WMS) Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573The GetCapabilities Request. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573The GetMap Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575The GetFeatureInfo Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576Spatial Reference Systems (SRS) Mapping. . . . . . . . . . . . . . . . . . . . . . . . . 578
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
PART 5 ■ ■ ■ Spatial in Applications
■CHAPTER 14 Sample Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Data Preparation and Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582Loading the Geographical Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582Location-Enabling the Application Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . 582Loading Map, Theme, Style, and Map Cache Definitions
for MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583Applications Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583The JavaScript Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
Application Walk-Through. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584Under the Hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
■CONTENTS xiii
8997ch00FM.qxt 9/28/07 9:52 AM Page xiii
www.it-ebooks.info
The Java (JSP) Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Application Walk-Through. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Under the Hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622
■CHAPTER 15 Case Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
Overview of the Case Studies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623Spatial Information for Managing the London Bus Network . . . . . . . . . . . . . . . . 624
BusNet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625Spatial Data and Oracle Spatial in BusNet . . . . . . . . . . . . . . . . . . . . . . . . . 626User Interface for Spatial Data in BusNet . . . . . . . . . . . . . . . . . . . . . . . . . . 628BusNet Conclusions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630
P-Info: A Mobile Application for Police Forces. . . . . . . . . . . . . . . . . . . . . . . . . . . . 631P-Info Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632P-Info Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633Use of Oracle Spatial in P-Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635Measurable Added Value of P-Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Risk Repository for Hazardous Substances. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638RRGS Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640Use of Oracle Spatial in the RRGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642From Hazardous Substances to Risk Management . . . . . . . . . . . . . . . . . . 643
USGS National Land Cover Visualization and Analysis Tool . . . . . . . . . . . . . . . . . 644The Architecture of USGS Visualization and Analysis Tool . . . . . . . . . . . . . 647Oracle Spatial in USGS Visualization and Analysis Tool . . . . . . . . . . . . . . . 648Benefits of USGS Visualization and Analysis Tool . . . . . . . . . . . . . . . . . . . . 651
U.S. Department of Defense MilitaryHOMEFRONT LBS . . . . . . . . . . . . . . . . . . . . 652The Architecture of MilitaryHOMEFRONT LBS . . . . . . . . . . . . . . . . . . . . . . 654Oracle Spatial in MilitaryHOMEFRONT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657Mobile MilitaryINSTALLATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660Benefits of MilitaryHOMEFRONT LBS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662
■CHAPTER 16 Tips, Common Mistakes, and Common Errors . . . . . . . . . . . . . . 663
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663Data Modeling and Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663Performance of Spatial Operator Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . 666Performance of Other Spatial Processing Functions . . . . . . . . . . . . . . . . . 670Performance of Inserts, Deletes, and Updates . . . . . . . . . . . . . . . . . . . . . . 672Best Practices for Scalability and Manageability of Spatial Indexes . . . . 673
Common Mistakes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678Bounds, Longitude and Latitude, and Tolerance for Geodetic Data . . . . . 678NULL Values for SDO_GEOMETRY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
■CONTENTSxiv
8997ch00FM.qxt 9/28/07 9:52 AM Page xiv
www.it-ebooks.info
Use GEOCODE or GEOCODE_ALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678Specify “INDEXTYPE is mdsys.spatial_index” in CREATE INDEX . . . . . . . 678Always Use Spatial Operators in the WHERE Clause . . . . . . . . . . . . . . . . . 679Use Spatial Functions When No Spatial Index Is Available . . . . . . . . . . . . 679Do Not Move, Import, or Replicate MDRT Tables . . . . . . . . . . . . . . . . . . . . 680Network Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680Map Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681
Common Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681ORA-13226: Interface Not Supported Without a Spatial Index . . . . . . . . . 681ORA-13203: Failed to Read USER_SDO_GEOM_METADATA View . . . . . . 681ORA-13365: Layer SRID Does Not Match Geometry SRID. . . . . . . . . . . . . 681ORA-13223: Duplicate Entry for <table_name, column_name> in
SDO_GEOM_METADATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682ORA-13249, ORA-02289: Cannot Drop Sequence/Table . . . . . . . . . . . . . . 682ORA-13249: Multiple Entries in sdo_index_metadata Table. . . . . . . . . . . 682ORA-13207: Incorrect Use of the <operator-name> Operator . . . . . . . . . 682ORA-13000: Dimension Number Is Out of Range. . . . . . . . . . . . . . . . . . . . 682ORA-00904: . . . Invalid Identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683ORA-00939: Too Many Arguments for Function . . . . . . . . . . . . . . . . . . . . . 683ORA-13030: Invalid Dimensionality for the SDO_GEOMETRY,
or ORA-13364: Layer Dimensionality Does Not Match GeometryDimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
PART 6 ■ ■ ■ Appendixes
■APPENDIX A Additional Spatial Analysis Functions . . . . . . . . . . . . . . . . . . . . . . . 689
Tiling-Based Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689TILED_BINS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689TILED_AGGREGATES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
Neighborhood Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694AGGREGATES_FOR_GEOMETRY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694AGGREGATES_FOR_LAYER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
Clustering Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696SPATIAL_CLUSTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
Refining the Candidates for Site Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697Geometry Simplification for Speeding Up Analysis. . . . . . . . . . . . . . . . . . . . . . . . 698Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
■CONTENTS xv
8997ch00FM.qxt 9/28/07 9:52 AM Page xv
www.it-ebooks.info
■APPENDIX B Linear Referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
Concepts and Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702Measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702Linear Referenced Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702Direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702Shape Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702Offset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703Typical Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
Creating Linear Referenced Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705SDO_GTYPE in LRS Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705Constructing LRS Geometries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707Spatial Indexes and Spatial Operators on LRS Geometries . . . . . . . . . . . . 707
Dynamic Segmentation Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707Clip a Segment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707Locate a Point. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708Project a Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709Intersecting LRS Segments with Standard Geometries . . . . . . . . . . . . . . . 710Validation of LRS Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710Dynamic Segmentation on 3D Geometries . . . . . . . . . . . . . . . . . . . . . . . . . 711Other Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
■APPENDIX C Topology Data Model in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
Sharing Boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714Benefits of the Topology Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715Storing a Topology Data Model in Oracle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715Operating on a Topology in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
Creating a Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718Populating a Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719Associating a Feature Layer with a Topology . . . . . . . . . . . . . . . . . . . . . . . 719Inserting, Updating, and Populating Feature Layers. . . . . . . . . . . . . . . . . . 720Updating Topological Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721Querying for Topological Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
Hierarchical Feature Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
■APPENDIX D Storing Raster Data in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
The SDO_GEORASTER Data Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726Storage for SDO_GEORASTER Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728Metadata in SDO_GEORASTER Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
■CONTENTSxvi
8997ch00FM.qxt 9/28/07 9:52 AM Page xvi
www.it-ebooks.info
Populating SDO_GEORASTER Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731Manipulating Raster Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
Generating Pyramids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733Subsetting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734Georeferencing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734Attaching Bitmap Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736Registering NODATA Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
Using Compression in GeoRaster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738Visualizing Raster Data in Oracle MapViewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
■APPENDIX E Three-Dimensional Modeling Using Point Clouds and TINs in Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
Storing Large Point Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744The SDO_PC Data Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744Populating a Point Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745Querying a Point Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748Other Manipulation Functions for Point Clouds. . . . . . . . . . . . . . . . . . . . . . 749
Storing Triangulated Irregular Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749The SDO_TIN Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750Populating a TIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751Querying a TIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754Other Manipulation Functions for TINs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757
■CONTENTS xvii
8997ch00FM.qxt 9/28/07 9:52 AM Page xvii
www.it-ebooks.info