Pan Select Clear "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // LinearRing contains a Point : false for a point outside of the AABB of the LinearRing testExpectedResult = false; geom1 = ((layer.getChildAt(9) as PolygonFeature).geometry as Collection).componentByIndex(0); geom2 = (layer.getChildAt(0) as PointFeature).geometry; testResult = (geom1 as LinearRing).containsPoint(geom2 as org.openscales.core.geometry.Point); textResult = "Does the outer LinearRing of the blue Polygon contain the black point below the violet multipolygon (false) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // LinearRing contains a Point : false even if the point is inside the AABB of the LinearRing testExpectedResult = false; geom1 = ((layer.getChildAt(9) as PolygonFeature).geometry as Collection).componentByIndex(0); geom2 = (layer.getChildAt(2) as PointFeature).geometry; testResult = (geom1 as LinearRing).containsPoint(geom2 as org.openscales.core.geometry.Point); textResult = "Does the outer LinearRing of the blue Polygon contain the nearest black point (false) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // Polygon contains a Point without management of the holes : true testExpectedResult = true; geom1 = (layer.getChildAt(9) as PolygonFeature).geometry; geom2 = (layer.getChildAt(5) as PointFeature).geometry; testResult = (geom1 as Polygon).isPointInPolygon(geom2 as org.openscales.core.geometry.Point, false); textResult = "Does the blue Polygon contain the red point without managing its holes (true) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // Polygon contains a Point with management of the holes : false testExpectedResult = false; geom1 = (layer.getChildAt(9) as PolygonFeature).geometry; geom2 = (layer.getChildAt(5) as PointFeature).geometry; testResult = (geom1 as Polygon).containsPoint(geom2 as org.openscales.core.geometry.Point); textResult = "Does the blue Polygon contain the red point without managing its holes (false) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // MultiPolygon contains a Point : true testExpectedResult = true; geom1 = ((layer.getChildAt(10) as MultiPolygonFeature).geometry as Collection).componentByIndex(0) as Collection; geom2 = (layer.getChildAt(0) as PointFeature).geometry; testResult = (geom1 as Polygon).containsPoint(geom2 as org.openscales.core.geometry.Point); textResult = "Does the violet MultiPolygon contain the upper black point (true) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // MultiPolygon contains a Point : false testExpectedResult = false; geom1 = ((layer.getChildAt(10) as MultiPolygonFeature).geometry as Collection).componentByIndex(0) as Collection; geom2 = (layer.getChildAt(1) as PointFeature).geometry; testResult = (geom1 as Polygon).containsPoint(geom2 as org.openscales.core.geometry.Point); textResult = "Does the violet MultiPolygon contain the lower black point (false) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); } /** * Test all the intersects functions for the relevant geometries. */ public function testIntersects(layer:FeatureLayer):void { // Useful variables for the tests var geom1:Geometry, geom2:Geometry; var testResult:Boolean, testExpectedResult:Boolean; var textResult:String; // Polygon intersect a Polygon : true testExpectedResult = true; geom1 = (layer.getChildAt(9) as PolygonFeature).geometry; geom2 = (layer.getChildAt(4) as PolygonFeature).geometry; testResult = (geom1 as Polygon).intersects(geom2 as org.openscales.core.geometry.Polygon); textResult = "Does the blue Polygon intersect the big black rectangle (true) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // Polygon intersect a Polygon : true testExpectedResult = true; geom1 = (layer.getChildAt(9) as PolygonFeature).geometry; geom2 = (layer.getChildAt(11) as PolygonFeature).geometry; testResult = (geom1 as Polygon).intersects(geom2 as org.openscales.core.geometry.Polygon); textResult = "Does the blue Polygon intersect the inside small black rectangle (true) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); // Polygon intersect a Polygon : false testExpectedResult = false; geom1 = (layer.getChildAt(9) as PolygonFeature).geometry; geom2 = (layer.getChildAt(12) as PolygonFeature).geometry; testResult = (geom1 as Polygon).intersects(geom2 as org.openscales.core.geometry.Polygon); textResult = "Does the blue Polygon intersect the black lozenge (false) ? => "+testResult; if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult); } ]]>