@@ -90,53 +90,24 @@ function setZ!(ptr::GEOSCoordSeq, i::Integer, value::Real, context::GEOSContext
9090 result
9191end
9292
93- # Get ordinate values from a Coordinate Sequence (Return 0 on exception)
94- function getX! (ptr:: GEOSCoordSeq , index:: Integer , coord:: Vector{Float64} , context:: GEOSContext = _context)
95- result = GEOSCoordSeq_getX_r (context. ptr, ptr, index- 1 , pointer (coord))
93+ " Get size info from a Coordinate Sequence (Return 0 on exception)"
94+ function getSize (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
95+ out = Ref {UInt32} ()
96+ result = GEOSCoordSeq_getSize_r (context. ptr, ptr, out)
9697 if result == 0
97- error (" LibGEOS: Error in GEOSCoordSeq_getX " )
98+ error (" LibGEOS: Error in GEOSCoordSeq_getSize " )
9899 end
99- result
100+ Int (out[])
100101end
101102
102- function getY! (ptr:: GEOSCoordSeq , index:: Integer , coord:: Vector{Float64} , context:: GEOSContext = _context)
103- result = GEOSCoordSeq_getY_r (context. ptr, ptr, index- 1 , pointer (coord))
103+ " Get dimensions info from a Coordinate Sequence (Return 0 on exception)"
104+ function getDimensions (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
105+ out = Ref {UInt32} ()
106+ result = GEOSCoordSeq_getDimensions_r (context. ptr, ptr, out)
104107 if result == 0
105- error (" LibGEOS: Error in GEOSCoordSeq_getY" )
106- end
107- result
108- end
109-
110- function getZ! (ptr:: GEOSCoordSeq , index:: Integer , coord:: Vector{Float64} , context:: GEOSContext = _context)
111- result = GEOSCoordSeq_getZ_r (context. ptr, ptr, index- 1 , pointer (coord))
112- if result == 0
113- error (" LibGEOS: Error in GEOSCoordSeq_getZ" )
114- end
115- result
116- end
117-
118- let out = Array {UInt32} (undef, 1 )
119- global getSize
120- function getSize (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
121- # Get size info from a Coordinate Sequence (Return 0 on exception)
122- result = GEOSCoordSeq_getSize_r (context. ptr, ptr, pointer (out))
123- if result == 0
124- error (" LibGEOS: Error in GEOSCoordSeq_getSize" )
125- end
126- Int (out[1 ])
127- end
128- end
129-
130- let out = Array {UInt32} (undef, 1 )
131- global getDimensions
132- function getDimensions (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
133- # Get dimensions info from a Coordinate Sequence (Return 0 on exception)
134- result = GEOSCoordSeq_getDimensions_r (context. ptr, ptr, pointer (out))
135- if result == 0
136- error (" LibGEOS: Error in GEOSCoordSeq_getDimensions" )
137- end
138- Int (out[1 ])
108+ error (" LibGEOS: Error in GEOSCoordSeq_getDimensions" )
139109 end
110+ Int (out[])
140111end
141112
142113# convenience functions
@@ -202,12 +173,13 @@ function createCoordSeq(coords::Vector{Vector{Float64}}, context::GEOSContext =
202173 coordinates
203174end
204175
205- let out = Array {Float64} (undef, 1 )
206- global getX
207- function getX ( ptr:: GEOSCoordSeq , i :: Integer , context :: GEOSContext = _context )
208- getX! (ptr, i, out, context)
209- out[ 1 ]
176+ function getX (ptr :: GEOSCoordSeq , i :: Integer , context :: GEOSContext = _context )
177+ out = Ref {Float64} ()
178+ result = GEOSCoordSeq_getX_r (context . ptr, ptr, i - 1 , out )
179+ if result == 0
180+ error ( " LibGEOS: Error in GEOSCoordSeq_getX " )
210181 end
182+ out[]
211183end
212184
213185function getX (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
@@ -221,13 +193,13 @@ function getX(ptr::GEOSCoordSeq, context::GEOSContext = _context)
221193 xcoords
222194end
223195
224- let out = Array {Float64} (undef, 1 )
225- global getY
226- function getY (ptr:: GEOSCoordSeq , i:: Integer , context:: GEOSContext = _context)
227- out = Array {Float64} (undef, 1 )
228- getY! (ptr, i, out, context)
229- out[1 ]
196+ function getY (ptr:: GEOSCoordSeq , i:: Integer , context:: GEOSContext = _context)
197+ out = Ref {Float64} ()
198+ result = GEOSCoordSeq_getY_r (context. ptr, ptr, i- 1 , out)
199+ if result == 0
200+ error (" LibGEOS: Error in GEOSCoordSeq_getY" )
230201 end
202+ out[]
231203end
232204
233205function getY (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
@@ -241,12 +213,13 @@ function getY(ptr::GEOSCoordSeq, context::GEOSContext = _context)
241213 ycoords
242214end
243215
244- let out = Array {Float64} (undef, 1 )
245- global getZ
246- function getZ ( ptr:: GEOSCoordSeq , i :: Integer , context :: GEOSContext = _context )
247- getZ! (ptr, i, out, context)
248- out[ 1 ]
216+ function getZ (ptr :: GEOSCoordSeq , i :: Integer , context :: GEOSContext = _context )
217+ out = Ref {Float64} ()
218+ result = GEOSCoordSeq_getZ_r (context . ptr, ptr, i - 1 , out )
219+ if result == 0
220+ error ( " LibGEOS: Error in GEOSCoordSeq_getZ " )
249221 end
222+ out[]
250223end
251224
252225function getZ (ptr:: GEOSCoordSeq , context:: GEOSContext = _context)
@@ -966,26 +939,22 @@ function numPoints(ptr::GEOSGeom, context::GEOSContext = _context)
966939end
967940
968941# Return -1 on exception, Geometry must be a Point.
969- let out = Array {Float64} (undef, 1 )
970- global getGeomX
971- function getGeomX (ptr:: GEOSGeom , context:: GEOSContext = _context)
972- result = GEOSGeomGetX_r (context. ptr, ptr, pointer (out))
973- if result == - 1
974- error (" LibGEOS: Error in GEOSGeomGetX" )
975- end
976- out[1 ]
942+ function getGeomX (ptr:: GEOSGeom , context:: GEOSContext = _context)
943+ out = Ref {Float64} ()
944+ result = GEOSGeomGetX_r (context. ptr, ptr, out)
945+ if result == - 1
946+ error (" LibGEOS: Error in GEOSGeomGetX" )
977947 end
948+ out[]
978949end
979950
980- let out = Array {Float64} (undef, 1 )
981- global getGeomY
982- function getGeomY (ptr:: GEOSGeom , context:: GEOSContext = _context)
983- result = GEOSGeomGetY_r (context. ptr, ptr, pointer (out))
984- if result == - 1
985- error (" LibGEOS: Error in GEOSGeomGetY" )
986- end
987- out[1 ]
951+ function getGeomY (ptr:: GEOSGeom , context:: GEOSContext = _context)
952+ out = Ref {Float64} ()
953+ result = GEOSGeomGetY_r (context. ptr, ptr, out)
954+ if result == - 1
955+ error (" LibGEOS: Error in GEOSGeomGetY" )
988956 end
957+ out[]
989958end
990959
991960# Return NULL on exception, Geometry must be a Polygon.
@@ -1074,64 +1043,54 @@ end
10741043# -----
10751044# Misc functions
10761045# -----
1077- let out = Array {Float64} (undef, 1 )
1078- global geomArea
1079- function geomArea (ptr:: GEOSGeom , context:: GEOSContext = _context)
1080- # Return 0 on exception, 1 otherwise
1081- result = GEOSArea_r (context. ptr, ptr, pointer (out))
1082- if result == 0
1083- error (" LibGEOS: Error in GEOSArea" )
1084- end
1085- out[1 ]
1086- end
1087- end
1088-
1089- let out = Array {Float64} (undef, 1 )
1090- global geomLength
1091- function geomLength (ptr:: GEOSGeom , context:: GEOSContext = _context)
1092- # Return 0 on exception, 1 otherwise
1093- result = GEOSLength_r (context. ptr, ptr, pointer (out))
1094- if result == 0
1095- error (" LibGEOS: Error in GEOSLength" )
1096- end
1097- out[1 ]
1098- end
1099- end
1100-
1101- let out = Array {Float64} (undef, 1 )
1102- global geomDistance
1103- function geomDistance (g1:: GEOSGeom , g2:: GEOSGeom , context:: GEOSContext = _context)
1104- # Return 0 on exception, 1 otherwise
1105- result = GEOSDistance_r (context. ptr, g1, g2, pointer (out))
1106- if result == 0
1107- error (" LibGEOS: Error in GEOSDistance" )
1108- end
1109- out[1 ]
1110- end
1111- end
1112-
1113- let out = Array {Float64} (undef, 1 )
1114- global hausdorffdistance
1115- function hausdorffdistance (g1:: GEOSGeom , g2:: GEOSGeom , context:: GEOSContext = _context)
1116- # Return 0 on exception, 1 otherwise
1117- result = GEOSHausdorffDistance_r (context. ptr, g1, g2, pointer (out))
1118- if result == 0
1119- error (" LibGEOS: Error in GEOSHausdorffDistance" )
1120- end
1121- out[1 ]
1122- end
1123- end
1124-
1125- let out = Array {Float64} (undef, 1 )
1126- global hausdorffdistance
1127- function hausdorffdistance (g1:: GEOSGeom , g2:: GEOSGeom , densifyFrac:: Real , context:: GEOSContext = _context)
1128- # Return 0 on exception, 1 otherwise
1129- result = GEOSHausdorffDistanceDensify_r (context. ptr, g1, g2, densifyFrac, pointer (out))
1130- if result == 0
1131- error (" LibGEOS: Error in GEOSHausdorffDistanceDensify" )
1132- end
1133- out[1 ]
1046+ function geomArea (ptr:: GEOSGeom , context:: GEOSContext = _context)
1047+ out = Ref {Float64} ()
1048+ # Return 0 on exception, 1 otherwise
1049+ result = GEOSArea_r (context. ptr, ptr, out)
1050+ if result == 0
1051+ error (" LibGEOS: Error in GEOSArea" )
1052+ end
1053+ out[]
1054+ end
1055+
1056+ function geomLength (ptr:: GEOSGeom , context:: GEOSContext = _context)
1057+ out = Ref {Float64} ()
1058+ # Return 0 on exception, 1 otherwise
1059+ result = GEOSLength_r (context. ptr, ptr, out)
1060+ if result == 0
1061+ error (" LibGEOS: Error in GEOSLength" )
1062+ end
1063+ out[]
1064+ end
1065+
1066+ function geomDistance (g1:: GEOSGeom , g2:: GEOSGeom , context:: GEOSContext = _context)
1067+ out = Ref {Float64} ()
1068+ # Return 0 on exception, 1 otherwise
1069+ result = GEOSDistance_r (context. ptr, g1, g2, out)
1070+ if result == 0
1071+ error (" LibGEOS: Error in GEOSDistance" )
1072+ end
1073+ out[]
1074+ end
1075+
1076+ function hausdorffdistance (g1:: GEOSGeom , g2:: GEOSGeom , context:: GEOSContext = _context)
1077+ out = Ref {Float64} ()
1078+ # Return 0 on exception, 1 otherwise
1079+ result = GEOSHausdorffDistance_r (context. ptr, g1, g2, out)
1080+ if result == 0
1081+ error (" LibGEOS: Error in GEOSHausdorffDistance" )
1082+ end
1083+ out[]
1084+ end
1085+
1086+ function hausdorffdistance (g1:: GEOSGeom , g2:: GEOSGeom , densifyFrac:: Real , context:: GEOSContext = _context)
1087+ out = Ref {Float64} ()
1088+ # Return 0 on exception, 1 otherwise
1089+ result = GEOSHausdorffDistanceDensify_r (context. ptr, g1, g2, densifyFrac, out)
1090+ if result == 0
1091+ error (" LibGEOS: Error in GEOSHausdorffDistanceDensify" )
11341092 end
1093+ out[]
11351094end
11361095
11371096# Return 0 on exception, the closest points of the two geometries otherwise.
0 commit comments