Pro Oracle Spatial for
Oracle Database 11g
Ravi Kothuri, Albert Godfrind, and Euro Beinat
Pro Oracle Spatial for Oracle Database 11g
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 RenowClarke, 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 , or
visit .
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 , or visit .
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution 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 in the Source Code/Download
section.
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
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
786
■INDEX
USER_SDO_INDEX_METADATA view, 249, 252,
680, 684
USER_SDO_MAPS, USER_SDO_THEMES
dictionary view, 681
USER_SDO_MAPS view, 486, 489
USER_SDO_NETWORK_CONSTRAINTS view,
406–407, 410
USER_SDO_NETWORK_METADATA view,
354–355, 364, 415, 424, 680
USER_SDO_STYLES table, 524
USER_SDO_STYLES view, 463, 489, 681
USER_SDO_THEMES view, 476, 489
us_interstates table, 705
us_interstates_lrs table, 705
US_ROADS network, 357, 364
US_ROADS spatial network, 357
US_ROADS_LINK$ network table, 356
US_ROADS_NODE$ network table, 356
US_ROADS_PATH$ network table, 356
US_ROADS_PLINK$ network table, 356
us_states table, 44
<us_streets, location> spatial layer, 668
us_streets table, 357, 668
us_streets_dup table, 668
utilities, 6
utility networks, 349
UTL_HTTP package, 566
utlxplan script, 280
V
validate( ) method, 230
validate(double tolerance) method, 229
VALIDATE_GEOMETRY_WITH_CONTEXT
function, 132–133, 134, 142, 710
VALIDATE_LAYER_WITH_CONTEXT function,
132, 133, 141
VALIDATE_NETWORK function, 362
VALIDATE_xxxx_SCHEMA functions, 363
validating
data, 663
linear referenced segments, 710
network structures, 362–363
spatial data, 132–141
functions, 132–133
geometry types, 133–141
VALID_GEOM_SEGMENT function, 710
VALID_LRS_PT function, 710
VALID_MEASURE function, 710
Value-Attribute Table (VAT), 728
VARCHAR2 data type, 40
VARCHAR2 string, 132
variable color scheme style, 471
Variable Marker advanced style, 470
variable marker style, 471
variable pie chart style, 473
varying arrays (VARRAYs), 211–215
declaring, 213
extending, 214
finding capacity of, 213
getting value of specific entries, 213
initializing, 213
ranging over all values in, 213–214
shrinking, 214–215
vector drawings, 465
vector model, 725
vector spatial data, 8
verifying
addresses, 188–193
network connectivity, 365–366
vertical coordinate systems
(CMPD_VERT_SRID), 69
vertices, 56, 58
visualization analysis, 208
visualizing
raster data in Oracle MapViewer, 739–740
spatial data, 50–51
voided polygons, 84, 85, 87
voids, 57
volatile copy, 349
volume functions, 326–330
volume method, 330
volume(double tolerance) method, 229
W
weather_patterns table, 675
web-examples.zip file, 583
Web Map Service (OGC WMS) interface,
573–578
GetCapabilities request, 573–575
GetFeatureInfo request, 576–578
GetMap request, 575–576
spatial reference systems (SRS) mapping, 578
web map services, creating map caches on,
499–502
Web Map Services (WMS), 499–500, 503
web service, 417
web.xml file, 420, 422
well-known binary (WKB), 60, 124, 232, 233–234
well-known text (WKT), 60, 124, 232–233
WFS themes, 539
WHERE clause, 208, 253–254, 263, 265, 297, 342
specifying partition key in, 677
using spatial operators in, 679
width attribute, 523
width parameter, 553, 576
Wireless data services, 6
withinCost( ) method, 375
WKT/WKB formats, 124
WKTEXT column, 46, 66
WKTEXT field, 66, 70
WMS themes, 539
WORK_TABLESPACE parameter, 250
WORK_TABLESPACE=TBS_3 parameter, 250
writeNetwork( ) method, 371, 394
X
X attribute, 207, 523, 551
X parameter, 577
xdivs parameter, 691
<xfm> element, 566
■INDEX
XMLHttpRequest object, 602
xmlparserv2.jar file, 412
Xms option, 412
Xmx option, 399, 412
Y
Y attribute, 207, 523, 551
Y parameter, 577
ydivs parameter, 691
Z
Z attribute, 207
zip5_dc function, 694
zip5_dc table, 691
zoom in, 509, 547
Zoom In button, 414, 606
zoom levels, 496–497
zoom out, 509, 547
Zoom Out button, 414, 606
zoomIn( ) method, 534, 612
zooming, 485, 509, 514–515, 533–535, 606,
612–613
zoom_level_change, 528
Find it faster at />
XML, 427–434, 503–505
batch routing, 432–434
geographic start/end locations, 432
pregeocoded start/end locations, 431–432
routing options, 431
routing requests, 430–431
XML API, 552–566
adding themes to base maps, 555–556
constructing maps from themes, 557–558
dynamic features, 561–563
dynamic themes, 558–560
legends, 563–564
overview, 552
simple map requests, 553–555
using multiple data sources, 556
XML map response, 565–566
XML Mode button, 496
XML queries/responses, 200–206
batch geocoding, 204–205
geocoding requests, 202–204
reverse geocoding, 205–206
XMLFOREST function, 126
XMLHTTPRequest mechanism, 602–603
787