Java Topology Suite in Action: Combining ESRI and Open Source
Java Topology Suite in Action: Combining ESRI and Open Source
Java Topology Suite in Action: Combining ESRI and Open Source
Jared Erickson
Pierce County, WA
Introduction
Combing ESRI and Open Source GIS
GeometryCollection
JTSIO
Owner Notify
Reverse Geocode
Profile
CountyView Web: Owner Notify
CountyView Web: Owner Notify
Buffer the user’s selected map feature:
// For each contour, find the intersection between the users LineString and
// the contour
Geometry intersection = lineString.intersection(geometry);
// Get the coordinate of this intersection and calculate the distance along and percent
// long the LineString
Coordinate coordinate = ((Point)intersection.getGeometryN(i)).getCoordinate();
LinearLocation loc = lineRef.project(coordinate);
LengthLocationMap locationMap = new LengthLocationMap(lineString);
double distanceAlong = locationMap.getLength(loc);
double percentAlong = distanceAlong / lineLength;
GIS Web Services
GIS Web Services
Pierce County GIS web services
Geocoders, Spatial Queries, Projection, Open
@, Tile Caches, Data
SOAP, XML, CSV, JSON, KML
Reprojection
JTS and GeoTools
GIS Web Services: Spatial Queries
Buffer service
Parameters Point, Distance, Layer
Buffer the Point by the Distance
Turn buffered Polygon into ArcIMS AXL or
ArcSDE Geometry (or WKT for PostGIS)
Perform spatial query
Turn AXL, ArcSDE Geometry, WKT back into
JTS Geometry
GIS Web Services: Projection
Uses JTS and GeoTools
Uses European Petroleum Survey Group
(EPSG)
EPSG:4326 is WGS 84
EPSG:2927 is WA State Plane South (feet)
JTS to AXL
Point(10,20) to <POINT x="10.0" y="20.0" />
AXL
<POINT x="1.0" y="1.0" />
GeoJSON
{"type":"Point","coordinates":[1,1]}
GeoRSS
<georss:point>1.0 1.0</georss:point>
GML
<gml:Point xmlns:gml="http://www.opengis.net/gml">
<gml:coordinates>1.0,1.0</gml:coordinates>
</gml:Point>
GPX
<wpt xmlns="http://www.topografix.com/GPX/1/1" lat="1.0" lon="1.0" />
KML
<Point><coordinates>1.0,1.0</coordinates></Point>
JTSIO Geometry/Format Matrix
axl geo geo Geo Geo Geo Geo gml gmlDoc gpx Gpx kml Kml wkt
Json JsonDoc Rss Rss Rss Rss Doc Doc
Doc Gml Gml
Doc
Point TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
Multi TRUE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE
Point
Line TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
String
Linear TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
Ring
Polygon TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE
Multi FALSE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
LineString
Multi TRUE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE
Polygon
Geometry FALSE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE
Collection
JTSIO in action
GeometryFactory geometryFactory = new GeometryFactory();
Coordinate coord = new Coordinate(5.1, 5.2);
Point point = geometryFactory.createPoint(coord);
{"type":"Point","coordinates":[5.1,5.2]}
Response
POLYGON ((108920.33 753808.59, 108910.72264020162 753711.044838992,
108882.26976625565 753617.2482838174, 108836.06480615128 753530.8048834902,
108773.88339059327 753455.0366094067, 108698.1151165098 753392.8551938487,
108611.67171618255 753346.6502337443, 108517.87516100807 753318.1973597984,
108420.33 753308.59, 108322.78483899194 753318.1973597984, 108228.98828381745
753346.6502337443, 108142.5448834902 753392.8551938487, 108066.77660940673
753455.0366094067, 108004.59519384873 753530.8048834902, 107958.39023374436
753617.2482838174, 107929.93735979838 753711.044838992, 107920.33 753808.59,
107929.93735979838 753906.135161008, 107958.39023374436 753999.9317161825,
108004.59519384873 754086.3751165097, 108066.77660940673 754162.1433905932,
108142.5448834902 754224.3248061512, 108228.98828381745 754270.5297662556,
108322.78483899194 754298.9826402016, 108420.33 754308.59, 108517.87516100807
754298.9826402016, 108611.67171618255 754270.5297662556, 108698.1151165098
754224.3248061512, 108773.88339059327 754162.1433905932, 108836.06480615128
754086.3751165097, 108882.26976625565 753999.9317161825, 108910.72264020162
753906.135161008, 108920.33 753808.59))
JTS Web Processing and OpenLayers
/**
* Create a custom buffer point tool
*/
function createBufferPointTool() {
var tool = new OpenLayers.Control();
OpenLayers.Util.extend(tool, {
draw: function () {
this.handler = new OpenLayers.Handler.Point(tool,{"done": this.notice});
},
notice: function (pt) {
var distanceStr = prompt("Enter buffer distance:");
if (!distanceStr || isNaN(distanceStr)) {
alert("Please enter a distance!");
return;
}
var distance = parseFloat(distanceStr);
var geoJsonFormat = new OpenLayers.Format.GeoJSON();
var geoJson = geoJsonFormat.write(pt,false);
$.ajax({
type: "POST",
url: “/jts/services/geoJson/buffer”,
data: {
"geometry": geoJson,
"distance": distance
},
dataType: 'json',
success: function(json){
var geoJsonFormat = new OpenLayers.Format.GeoJSON();
var feature = geoJsonFormat.read(json);
if (json) {
vlayer.addFeatures(feature);
}
},
error: function(request, text, error) {
alert("Error buffering point!");
}
});
},
CLASS_NAME: "OpenLayers.Control.BufferPointTool",
displayClass: "olControlBufferPointTool",
type: OpenLayers.Control.TYPE_TOOL
});
return tool;
}
JTS Web Processing and OpenLayers
Conclusion
GIS Software Development doesn’t have to
be either (ESRI) or (Open Source)