diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-16 18:48:08 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-16 18:48:08 -0700 |
commit | 15c4b6b21a31c63bc0f7e624e26d032d531c459d (patch) | |
tree | 524ca1dd9aca6ef0ea8db2910a16a3e227e8c1fb /src/main/java/org/traccar/model/Geofence.java | |
parent | ee9abd94265eb704b5f5dd2262f1a3460bbe2a8f (diff) | |
download | trackermap-server-15c4b6b21a31c63bc0f7e624e26d032d531c459d.tar.gz trackermap-server-15c4b6b21a31c63bc0f7e624e26d032d531c459d.tar.bz2 trackermap-server-15c4b6b21a31c63bc0f7e624e26d032d531c459d.zip |
Refactor geofence classes
Diffstat (limited to 'src/main/java/org/traccar/model/Geofence.java')
-rw-r--r-- | src/main/java/org/traccar/model/Geofence.java | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/model/Geofence.java b/src/main/java/org/traccar/model/Geofence.java index 5b857580d..9259028fb 100644 --- a/src/main/java/org/traccar/model/Geofence.java +++ b/src/main/java/org/traccar/model/Geofence.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,26 +15,19 @@ */ package org.traccar.model; -import java.text.ParseException; - -import org.traccar.Context; -import org.traccar.config.Keys; -import org.traccar.storage.QueryIgnore; +import com.fasterxml.jackson.annotation.JsonIgnore; import org.traccar.geofence.GeofenceCircle; import org.traccar.geofence.GeofenceGeometry; import org.traccar.geofence.GeofencePolygon; import org.traccar.geofence.GeofencePolyline; - -import com.fasterxml.jackson.annotation.JsonIgnore; +import org.traccar.storage.QueryIgnore; import org.traccar.storage.StorageName; +import java.text.ParseException; + @StorageName("tc_geofences") public class Geofence extends ScheduledModel { - public static final String TYPE_GEOFENCE_CILCLE = "geofenceCircle"; - public static final String TYPE_GEOFENCE_POLYGON = "geofencePolygon"; - public static final String TYPE_GEOFENCE_POLYLINE = "geofencePolyline"; - private String name; public String getName() { @@ -68,9 +61,7 @@ public class Geofence extends ScheduledModel { } else if (area.startsWith("POLYGON")) { geometry = new GeofencePolygon(area); } else if (area.startsWith("LINESTRING")) { - final double distance = getDouble("polylineDistance"); - geometry = new GeofencePolyline(area, distance > 0 ? distance - : Context.getConfig().getDouble(Keys.GEOFENCE_POLYLINE_DISTANCE)); + geometry = new GeofencePolyline(area); } else { throw new ParseException("Unknown geometry type", 0); } @@ -92,4 +83,5 @@ public class Geofence extends ScheduledModel { area = geometry.toWkt(); this.geometry = geometry; } + } |