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 Pro Oracle Spatial for 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 11g Dear 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 Beginning Oracle Programming Beginning PL/SQL Mastering Oracle SQL & SQL*Plus Mastering Oracle PL/SQL Pro Oracle Spatial for Oracle Database 11g Kothuri, Godfrind, Beinat cyan MaGenTa yellOW Black PanTOne 123 c Ravi Kothuri ISBN-13: 978-1-59059-899-3 ISBN-10: 1-59059-899-7 9 781590 598993 9 0 0 0 0 Shelve in Databases/Oracle User level: Intermediate–Advanced www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version Companion eBook Available Updated for Oracle Database 11g Updated for Oracle Database 11g Albert Godfrind Euro Beinat Kothuri, Godfrind, and Beinat coauthored Pro Oracle Spatial (first edition) Pro Oracle Spatial for Oracle Database 11g www.it-ebooks.info www.it-ebooks.info Ravi Kothuri, Albert Godfrind, and Euro Beinat Pro Oracle Spatial for Oracle Database 11 g 8997ch00FM.qxt 9/28/07 9:52 AM Page i www.it-ebooks.info Pro Oracle Spatial for Oracle Database 11 g Copyright © 2007 by Ravi Kothuri, Albert Godfrind, Euro Beinat All 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 retrieval system, 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 occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Jonathan Gennick Technical Reviewer: Carel-Jan Engel Editorial 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 Johnston Copy Editor: Kim Wimpsett Assistant Production Director: Kari Brooks-Copony Production Editor: Ellie Fountain Compositor: Kinetic Publishing Services, LLC Proofreader: Linda Seifert Indexer: Broccoli Information Management Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing 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 orders-ny@springer-sbm.com, or visit 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 info@apress.com, 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 any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or 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/Download section. 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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Sources of Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Managing and Analyzing Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Storing Spatial Data in a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Spatial Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Benefits of Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 ■CHAPTER 2 Overview of Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Technology and Architecture Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Getting Started with Oracle Spatial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Data Model: Storing Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Location-Enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Query and Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Visualizing Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Advanced Spatial Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Oracle Spatial Technology Products. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Locator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Spatial Option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 What to Expect in an Oracle Spatial Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Installing Oracle Spatial in the Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Upgrades. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Understanding a Spatial Install. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Checking the Version of a Spatial Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 v 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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Application-Specific Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Geographic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Metadata for Spatial Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Dictionary View for Spatial Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Populating Spatial Metadata for Your Application. . . . . . . . . . . . . . . . . . . . . . . . . . 49 Additional 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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Line Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Polygons and Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Solids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Logical Implementation of SDO_GEOMETRY . . . . . . . . . . . . . . . . . . . . . . . . 58 Spatial Data in SQL/MM and OGC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 SDO_GEOMETRY Type, Attributes, and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 SDO_GTYPE Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 SDO_SRID Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 SDO_POINT Attribute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 SDO_ELEM_INFO and SDO_ORDINATES Attributes . . . . . . . . . . . . . . . . . . . 74 Simple Two-Dimensional Geometry Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Line String: Connected by Straight Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Line String: Connected by Arcs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Polygon: Ring (Boundary) Connected by Straight Lines. . . . . . . . . . . . . . . . 80 Polygon: Ring (Boundary) Connected by Arcs . . . . . . . . . . . . . . . . . . . . . . . . 82 Rectangle Polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Circle Polygon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Complex Two-Dimensional Geometry Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Constructing Complex Geometries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 SDO_ELEM_INFO for Compound Elements. . . . . . . . . . . . . . . . . . . . . . . . . . 86 SDO_ELEM_INFO for Voided Polygon Element . . . . . . . . . . . . . . . . . . . . . . . 87 Compound Line String Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Compound Polygon Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Polygon with a Void . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 ■CONTENTSvi 8997ch00FM.qxt 9/28/07 9:52 AM Page vi www.it-ebooks.info Three-Dimensional Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Three-Dimensional Points, Lines, and Polygons. . . . . . . . . . . . . . . . . . . . . . 97 Composite Surfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Simple Solid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Composite Solid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 ■CHAPTER 5 Loading, Transporting, and Validating Spatial Data . . . . . . . . 115 Inserting Data into an SDO_GEOMETRY Column . . . . . . . . . . . . . . . . . . . . . . . . . 116 Loading and Converting Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Loading from Text Files Using SQL*Loader . . . . . . . . . . . . . . . . . . . . . . . . . 117 Transporting Spatial Data Between Oracle Databases. . . . . . . . . . . . . . . . 120 Loading from External Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Converting Between SDO_GEOMETRY and WKT/WKB. . . . . . . . . . . . . . . . 124 Converting SDO_GEOMETRY Data in GML . . . . . . . . . . . . . . . . . . . . . . . . . 124 Extruding a Two-Dimensional Geometry to Three Dimensions . . . . . . . . . . . . . . 129 Validating Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Validation Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Validation Criteria. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Composite Solids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Debugging Spatial Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 REMOVE_DUPLICATE_VERTICES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 EXTRACT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 APPEND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 GETNUMELEM, GETNUMVERTICES, and GETVERTICES . . . . . . . . . . . . . . . 147 EXTRACT3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Miscellaneous Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 ■CHAPTER 6 Geocoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 What Is Geocoding?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Architecture of the Oracle Geocoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Parsing the Input Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Searching for the Address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Computing the Spatial Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Setting Up the Reference Data for the Geocoder . . . . . . . . . . . . . . . . . . . . . . . . . 156 Parameter Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Data Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 ■CONTENTS vii 8997ch00FM.qxt 9/28/07 9:52 AM Page vii www.it-ebooks.info Using Geocoder Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 GEOCODE_AS_GEOMETRY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 GEOCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 GEOCODE_ALL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Geocoding Using Structured Addresses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 GEOCODE_ADDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 GEOCODE_ADDR_ALL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Reverse Geocoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 REVERSE_GEOCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Geocoding Business Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Adding the Spatial Column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Geocoding the Addresses: The “Naive” Approach . . . . . . . . . . . . . . . . . . . 187 Address Verification and Correction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Automatic Geocoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 The Geocoding Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 Installation and Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Using the Geocoder: XML Queries and Responses. . . . . . . . . . . . . . . . . . . 200 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 ■CHAPTER 7 Manipulating SDO_GEOMETRY in Application Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Manipulating Geometries Using PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 VARRAY Manipulation Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Reading and Writing SDO_GEOMETRY Objects . . . . . . . . . . . . . . . . . . . . . 215 Creating New Geometries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Extracting Information from Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Modifying Existing Geometries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Manipulating Geometries in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Using the JGeometry Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Using 3D Geometries: the J3D_Geometry Class . . . . . . . . . . . . . . . . . . . . 229 Extracting Elements from 3D Geometries: the ElementExtractor Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Using Standard Notations: WKT, WKB, GML . . . . . . . . . . . . . . . . . . . . . . . . 232 Using ESRI Shapefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 ■CONTENTSviii 8997ch00FM.qxt 9/28/07 9:52 AM Page viii www.it-ebooks.info [...]... value to organizations Oracle Spatial has grown to be one of the most established solutions for providing spatial intelligence to databases Besides the extensive installed base of Oracle databases, Oracle Spatial manages spatial data just like any other data type, making it in principle easy for experienced database developers and architects to extend their scope into spatial information management Using... aspects of spatial information management: representation and storage using appropriate types, and analysis functionality for stored spatial data We then discuss the systems that enable spatial information management, such as GIS, and their evolution We finally look at the benefits of spatial information management using Oracle Spatial • Chapter 2: Overview of Oracle Spatial: The Oracle Spatial technology... or installation guide for details The complete documentation for Oracle Database and Oracle Application Server is available online on the Oracle Technology Network website at www .oracle. com/technology/documentation The Oracle 11g manuals relevant to this book are as follows: • Oracle Spatial User’s Guide and Reference • Oracle Application Server, MapViewer User’s Guide • Oracle Spatial Topology and... and links provided in support of this book This information is not provided in the book itself Setting Up Oracle Spatial and MapViewer If you already have a recent version of an Oracle database up and running, you most probably do not need to do anything specific to set up Oracle Spatial Oracle Spatial technology is automatically installed with the Standard or Enterprise Edition of an Oracle database. .. the potential of Oracle Spatial and how to use it at an advanced level We do not want to just familiarize you with Oracle Spatial; we want you to become an expert in Oracle Spatial What Does This Book Cover? This book covers spatial information management in the Oracle database In particular: • It introduces the main concepts of spatial information management and how they relate to database concepts... • You need to have Oracle Database 11g and Oracle Spatial installed and configured • You need to have Oracle MapViewer (part of Oracle Application Server) installed and configured The instructions for installing and configuring MapViewer are in Chapter 12 • You need to download data and scripts for this book from the Apress website (www.apress.com) The Oracle software (Database 11g, Application Server,... this chapter, we focus on spatial indexes and spatial operators Spatial indexes ensure effective response times for queries that perform proximity analysis The chapter introduces the concepts of spatial indexes and their creation We then describe different spatial operators that Oracle Spatial supports for performing spatial analysis for indexed tables We give an overview of their syntax and semantics... developers and prompt them to incorporate spatial aspects to existing applications However, the book should also attract GIS programmers or users, if only because this is the first book that addresses Oracle Spatial in its entirety In spite of its title, this book does in fact cover the full spectrum of geospatial technologies at Oracle that is, the database (Oracle Spatial and Locator) and also Oracle Application... you’ll find our book an invaluable guide for creating robust spatially enhanced applications that perform well Copyrights and Disclaimer Oracle is a registered trademark, and Oracle9 i, 10g, 11g, Oracle iAS (Application Server), and Oracle Spatial are trademarks of Oracle Corporation All other company and product names mentioned in the book are used for identification purposes only and may be trademarks of... of spatial operators In the final part of the chapter, we address some advanced spatial indexing features that are useful for large spatial repositories • Chapter 9: Geometry Processing Functions: In this chapter, we discuss geometry processing functions, simply referred to as spatial functions In contrast to the spatial operators, these geometry processing functions do not require a spatial index, provide . for Oracle Database 11g Updated for Oracle Database 11g Albert Godfrind Euro Beinat Kothuri, Godfrind, and Beinat coauthored Pro Oracle Spatial (first edition) Pro Oracle Spatial for Oracle Database 11g www.it-ebooks.info www.it-ebooks.info Ravi. Beinat Pro Oracle Spatial for Oracle Database 11g The essential guide to developing spatially enabled business applications using Oracle BOOks fOR PROfessIOnals By PROfessIOnals ® Pro Oracle Spatial. Albert Godfrind, and Euro Beinat Pro Oracle Spatial for Oracle Database 11 g 8997ch00FM.qxt 9/28/07 9:52 AM Page i www.it-ebooks.info Pro Oracle Spatial for Oracle Database 11 g Copyright © 2007