@@ -36,6 +36,7 @@ interpolateNormalized(line::LineString, dist::Float64) = Point(interpolateNormal
3636# # Topology operations
3737# # -----
3838for geom in (:Point , :MultiPoint , :LineString , :MultiLineString , :LinearRing , :Polygon , :MultiPolygon , :GeometryCollection )
39+ @eval buffer (obj:: $geom , dist:: Float64 , quadsegs:: Int = 8 ) = Polygon (buffer (obj. ptr, dist, quadsegs))
3940 @eval envelope (obj:: $geom ) = geomFromGEOS (envelope (obj. ptr))
4041 @eval convexhull (obj:: $geom ) = geomFromGEOS (convexhull (obj. ptr))
4142 @eval boundary (obj:: $geom ) = geomFromGEOS (boundary (obj. ptr))
@@ -77,6 +78,8 @@ for geom in (:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :P
7778 @eval simplify (obj:: $geom , tol:: Float64 ) = geomFromGEOS (simplify (obj. ptr, tol))
7879 @eval topologyPreserveSimplify (obj:: $geom , tol:: Float64 ) = geomFromGEOS (topologyPreserveSimplify (obj. ptr, tol))
7980 @eval uniquePoints (obj:: $geom ) = MultiPoint (uniquePoints (obj. ptr))
81+ @eval delaunayTriangulationEdges (obj:: $geom , tol:: Float64 = 0.0 ) = MultiLineString (delaunayTriangulation (obj. ptr, tol, true ))
82+ @eval delaunayTriangulation (obj:: $geom , tol:: Float64 = 0.0 ) = GeometryCollection (delaunayTriangulation (obj. ptr, tol, false ))
8083end
8184
8285sharedPaths (obj1:: LineString , obj2:: LineString ) = GeometryCollection (sharedPaths (obj1. ptr, obj2. ptr))
@@ -88,16 +91,6 @@ for g1 in (:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :Pol
8891 end
8992end
9093
91- # Return a Delaunay triangulation of the vertex of the given geometry
92- # @param g the input geometry whose vertex will be used as "sites"
93- # @param tolerance optional snapping tolerance to use for improved robustness
94- # @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
95- # return a GEOMETRYCOLLECTION containing triangular POLYGONs.
96- for geom in (:Point , :MultiPoint , :LineString , :MultiLineString , :LinearRing , :Polygon , :MultiPolygon , :GeometryCollection )
97- @eval delaunayTriangulationEdges (obj:: $geom , tol:: Float64 = 0.0 ) = MultiLineString (delaunayTriangulation (obj. ptr, tol, true ))
98- @eval delaunayTriangulation (obj:: $geom , tol:: Float64 = 0.0 ) = GeometryCollection (delaunayTriangulation (obj. ptr, tol, false ))
99- end
100-
10194# -----
10295# Binary predicates
10396# -----
@@ -229,10 +222,8 @@ for geom in (:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :P
229222 @eval isEmpty (obj:: $geom ) = isEmpty (obj. ptr)
230223 @eval isSimple (obj:: $geom ) = isSimple (obj. ptr)
231224 @eval isRing (obj:: $geom ) = isRing (obj. ptr)
225+ @eval isValid (obj:: $geom ) = isValid (obj. ptr)
232226 @eval hasZ (obj:: $geom ) = hasZ (obj. ptr)
233- @eval pointOnSurface (obj:: $geom ) = Point (pointOnSurface (obj. ptr))
234- @eval centroid (obj:: $geom ) = Point (centroid (obj. ptr))
235- @eval node (obj:: $geom ) = geomFromGEOS (node (obj. ptr))
236227end
237228
238229isClosed (obj:: LineString ) = isClosed (obj. ptr) # Call only on LINESTRING
@@ -255,14 +246,6 @@ isClosed(obj::LineString) = isClosed(obj.ptr) # Call only on LINESTRING
255246# # GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
256247# # };
257248
258- # function isValid(ptr::GEOSGeom)
259- # result = GEOSisValid(ptr)
260- # if result == 0x02
261- # error("LibGEOS: Error in GEOSisValid")
262- # end
263- # bool(result)
264- # end
265-
266249# # * return NULL on exception, a string to GEOSFree otherwise
267250# # GEOSisValidReason
268251
@@ -275,15 +258,6 @@ isClosed(obj::LineString) = isClosed(obj.ptr) # Call only on LINESTRING
275258# # Geometry info
276259# # -----
277260
278- # # Return NULL on exception, result must be freed by caller
279- # # function geomType(ptr::GEOSGeom)
280- # # result = GEOSGeomType(ptr)
281- # # if result == C_NULL
282- # # error("LibGEOS: Error in GEOSGeomType")
283- # # end
284- # # result
285- # # end
286-
287261# # May be called on all geometries in GEOS 3.x, returns -1 on error and 1
288262# # for non-multi geometries. Older GEOS versions only accept
289263# # GeometryCollections or Multi* geometries here, and are likely to crash
@@ -317,24 +291,6 @@ for geom in (:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :P
317291 @eval normalize! (obj:: $geom ) = normalize! (obj. ptr)
318292end
319293
320- # # Return -1 on exception
321- # function numInteriorRings(ptr::GEOSGeom)
322- # result = GEOSGetNumInteriorRings(ptr)
323- # if result == -1
324- # error("LibGEOS: Error in GEOSGetNumInteriorRings")
325- # end
326- # result
327- # end
328-
329- # # Call only on LINESTRING (returns -1 on exception)
330- # function numPoints(ptr::GEOSGeom)
331- # result = GEOSGeomGetNumPoints(ptr)
332- # if result == -1
333- # error("LibGEOS: Error in GEOSGeomGetNumPoints")
334- # end
335- # result
336- # end
337-
338294# # Return -1 on exception, Geometry must be a Point.
339295# function getGeomX(ptr::GEOSGeom)
340296# x = Array(Float64, 1)
354310# y[1]
355311# end
356312
357- # # Return NULL on exception, Geometry must be a Polygon.
358- # # Returned object is a pointer to internal storage: it must NOT be destroyed directly.
359- # function interiorRing(ptr::GEOSGeom, n::Int)
360- # result = GEOSGetInteriorRingN(ptr, int32(n))
361- # if result == C_NULL
362- # error("LibGEOS: Error in GEOSGetInteriorRingN")
363- # end
364- # result
365- # end
366-
367- # function interiorRings(ptr::GEOSGeom)
368- # n = numInteriorRings(ptr)
369- # if n == 0
370- # return GEOSGeom[]
371- # else
372- # return GEOSGeom[GEOSGetInteriorRingN(ptr, int32(i)) for i=0:n-1]
373- # end
374- # end
375-
376- # # Return NULL on exception, Geometry must be a Polygon.
377- # # Returned object is a pointer to internal storage: it must NOT be destroyed directly.
378- # function exteriorRing(ptr::GEOSGeom)
379- # result = GEOSGetExteriorRing(ptr)
380- # if result == C_NULL
381- # error("LibGEOS: Error in GEOSGetExteriorRing")
382- # end
383- # result
384- # end
313+ interiorRings (obj:: Polygon ) = map (LinearRing, interiorRings (obj. ptr))
314+ exteriorRing (obj:: Polygon ) = LinearRing (exteriorRing (obj. ptr))
385315
386316# # Return -1 on exception
387317# function numCoordinates(ptr::GEOSGeom)
@@ -417,63 +347,25 @@ end
417347# result
418348# end
419349
350+ numPoints (obj:: LineString ) = numPoints (obj. ptr) # Call only on LINESTRING
420351startPoint (obj:: LineString ) = Point (startPoint (obj. ptr)) # Call only on LINESTRING
421352endPoint (obj:: LineString ) = Point (endPoint (obj. ptr)) # Call only on LINESTRING
422353
423354# # -----
424355# # Misc functions
425356# # -----
426- # function geomArea(ptr::GEOSGeom)
427- # area = Array(Float64, 1)
428- # # Return 0 on exception, 1 otherwise
429- # result = GEOSArea(ptr, pointer(area))
430- # if result == 0
431- # error("LibGEOS: Error in GEOSArea")
432- # end
433- # area[1]
434- # end
435-
436- # function geomLength(ptr::GEOSGeom)
437- # len = Array(Float64, 1)
438- # # Return 0 on exception, 1 otherwise
439- # result = GEOSLength(ptr, pointer(len))
440- # if result == 0
441- # error("LibGEOS: Error in GEOSLength")
442- # end
443- # len[1]
444- # end
445-
446- # function geomDistance(g1::GEOSGeom, g2::GEOSGeom)
447- # dist = Array(Float64, 1)
448- # # Return 0 on exception, 1 otherwise
449- # result = GEOSDistance(g1, g2, pointer(dist))
450- # if result == 0
451- # error("LibGEOS: Error in GEOSDistance")
452- # end
453- # dist[1]
454- # end
455-
456- # function hausdorffdistance(g1::GEOSGeom, g2::GEOSGeom)
457- # dist = Array(Float64, 1)
458- # # Return 0 on exception, 1 otherwise
459- # result = GEOSHausdorffDistance(g1, g2, pointer(dist))
460- # if result == 0
461- # error("LibGEOS: Error in GEOSHausdorffDistance")
462- # end
463- # dist[1]
464- # end
465-
466- # function hausdorffdistance(g1::GEOSGeom, g2::GEOSGeom, densifyFrac::Float64)
467- # dist = Array(Float64, 1)
468- # # Return 0 on exception, 1 otherwise
469- # result = GEOSHausdorffDistanceDensify(g1, g2, densifyFrac, pointer(dist))
470- # if result == 0
471- # error("LibGEOS: Error in GEOSHausdorffDistanceDensify")
472- # end
473- # dist[1]
474- # end
357+ for geom in (:Point , :MultiPoint , :LineString , :MultiLineString , :LinearRing , :Polygon , :MultiPolygon , :GeometryCollection )
358+ @eval area (obj:: $geom ) = geomArea (obj. ptr)
359+ @eval geomLength (obj:: $geom ) = geomLength (obj. ptr)
360+ end
475361
476- getLength (obj:: LineString ) = getLength (obj. ptr) # Call only on LINESTRING
362+ for g1 in (:Point , :MultiPoint , :LineString , :MultiLineString , :LinearRing , :Polygon , :MultiPolygon , :GeometryCollection )
363+ for g2 in (:Point , :MultiPoint , :LineString , :MultiLineString , :LinearRing , :Polygon , :MultiPolygon , :GeometryCollection )
364+ @eval distance (obj1:: $g1 , obj2:: $g2 ) = geomDistance (obj1. ptr, obj2. ptr)
365+ @eval hausdorffdistance (obj1:: $g1 , obj2:: $g2 ) = hausdorffdistance (obj1. ptr, obj2. ptr)
366+ @eval hausdorffdistance (obj1:: $g1 , obj2:: $g2 , densify:: Float64 ) = hausdorffdistance (obj1. ptr, obj2. ptr, densify)
367+ end
368+ end
477369
478370# Returns the closest points of the two geometries. The first point comes from g1 geometry and the second point comes from g2.
479371for g1 in (:Point , :MultiPoint , :LineString , :MultiLineString , :LinearRing , :Polygon , :MultiPolygon , :GeometryCollection )
0 commit comments