Loading...
Searching...
No Matches
GeometryUtils.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class GeometryUtils {
34 {
35 return CppProxy.distanceBetweenGlobalPoints(from,
36 to);
37 }
38
55 public static float distanceBetweenPoints(Point from, Point to)
56 {
57 return CppProxy.distanceBetweenPoints(from,
58 to);
59 }
60
76 public static float segmentLength(Segment segment)
77 {
78 return CppProxy.segmentLength(segment);
79 }
80
96 public static float polygonArea(Polygon polygon)
97 {
98 return CppProxy.polygonArea(polygon);
99 }
100
116 public static Point polygonCenter(Polygon polygon)
117 {
118 return CppProxy.polygonCenter(polygon);
119 }
120
137 public static boolean polygonContainsPoint(Polygon polygon, Point point)
138 {
139 return CppProxy.polygonContainsPoint(polygon,
140 point);
141 }
142
159 public static float segmentPointDistance(Segment segment, Point point)
160 {
161 return CppProxy.segmentPointDistance(segment,
162 point);
163 }
164
181 public static boolean segmentIntersectsSegment(Segment segment1, Segment segment2)
182 {
183 return CppProxy.segmentIntersectsSegment(segment1,
184 segment2);
185 }
186
203 public static Point segmentIntersectionSegment(Segment segment1, Segment segment2)
204 {
205 return CppProxy.segmentIntersectionSegment(segment1,
206 segment2);
207 }
208
225 public static float divisionRatioBySegment(Segment segment1, Segment segment2)
226 {
227 return CppProxy.divisionRatioBySegment(segment1,
228 segment2);
229 }
230
247 public static Point getRatioPoint(Segment segment, double r)
248 {
249 return CppProxy.getRatioPoint(segment,
250 r);
251 }
252
270 public static double getProjectionRatio(Segment segment, Point point)
271 {
272 return CppProxy.getProjectionRatio(segment,
273 point);
274 }
275
276 private static final class CppProxy extends GeometryUtils
277 {
278 private final long nativeRef;
279 private final AtomicBoolean destroyed = new AtomicBoolean(false);
280
281 private CppProxy(long nativeRef)
282 {
283 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
284 this.nativeRef = nativeRef;
285 }
286
287 private native void nativeDestroy(long nativeRef);
288 public void _djinni_private_destroy()
289 {
290 boolean destroyed = this.destroyed.getAndSet(true);
291 if (!destroyed) nativeDestroy(this.nativeRef);
292 }
293 protected void finalize() throws java.lang.Throwable
294 {
295 _djinni_private_destroy();
296 super.finalize();
297 }
298
299 // GeometryUtils methods
300
301 public static native float distanceBetweenGlobalPoints(GlobalPoint from, GlobalPoint to);
302
303 public static native float distanceBetweenPoints(Point from, Point to);
304
305 public static native float segmentLength(Segment segment);
306
307 public static native float polygonArea(Polygon polygon);
308
309 public static native Point polygonCenter(Polygon polygon);
310
311 public static native boolean polygonContainsPoint(Polygon polygon, Point point);
312
313 public static native float segmentPointDistance(Segment segment, Point point);
314
315 public static native boolean segmentIntersectsSegment(Segment segment1, Segment segment2);
316
317 public static native Point segmentIntersectionSegment(Segment segment1, Segment segment2);
318
319 public static native float divisionRatioBySegment(Segment segment1, Segment segment2);
320
321 public static native Point getRatioPoint(Segment segment, double r);
322
323 public static native double getProjectionRatio(Segment segment, Point point);
324 }
325}