Commit eb6af7b2 authored by Noel Alonso's avatar Noel Alonso
Browse files

Pasa función a util

La función que comprueba si un punto está contenido en un área se pasa a
la util que contiene todas las utilidades geométricas.
parent b91468cd
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.locationtech.spatial4j.exception.InvalidShapeException;
import org.locationtech.spatial4j.shape.Shape;
import org.locationtech.spatial4j.shape.SpatialRelation;

import es.redmic.vesselrestrictionchecker.avro.hashmapserde.HashMapSerde;
import es.redmic.vesselrestrictionchecker.common.StreamsApplicationBase;
@@ -202,7 +201,7 @@ public class VesselRestrictionCheckerApplication extends StreamsApplicationBase
			// TODO: analizar si es necesario seguir procesando elementos una vez encontrada
			// un área.
			// Al menos no seguir procesando elementos de la misma área
			if (area.relate(point) == SpatialRelation.CONTAINS) {
			if (GeoUtils.shapeContainsGeometry(area, point)) {

				// Se crea una alerta con la info básica del punto y del área donde se encuentra
				PointInAreaAlert pointInAreaAlert = new PointInAreaAlert();
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import org.locationtech.spatial4j.io.WKTReader;
import org.locationtech.spatial4j.io.jts.JtsWKTWriter;
import org.locationtech.spatial4j.shape.Point;
import org.locationtech.spatial4j.shape.Shape;
import org.locationtech.spatial4j.shape.SpatialRelation;

public class GeoUtils {

@@ -118,4 +119,9 @@ public class GeoUtils {
		}
		return null;
	}

	public static boolean shapeContainsGeometry(Shape shape1, Shape shape2) {
		// The shape1 contains the target geometry.
		return (shape1.relate(shape2) == SpatialRelation.CONTAINS);
	}
}