aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/HemisphereHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/HemisphereHandler.java')
-rw-r--r--src/org/traccar/HemisphereHandler.java29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/org/traccar/HemisphereHandler.java b/src/org/traccar/HemisphereHandler.java
index b1e7d3fb2..d1bcd340b 100644
--- a/src/org/traccar/HemisphereHandler.java
+++ b/src/org/traccar/HemisphereHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 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,12 +15,11 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
import org.traccar.model.Position;
-import java.net.SocketAddress;
-
-public class HemisphereHandler extends ExtendedObjectDecoder {
+@ChannelHandler.Sharable
+public class HemisphereHandler extends BaseDataHandler {
private int latitudeFactor;
private int longitudeFactor;
@@ -45,20 +44,14 @@ public class HemisphereHandler extends ExtendedObjectDecoder {
}
@Override
- protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
-
- if (msg instanceof Position) {
- Position position = (Position) msg;
- if (latitudeFactor != 0) {
- position.setLatitude(Math.abs(position.getLatitude()) * latitudeFactor);
- }
- if (longitudeFactor != 0) {
- position.setLongitude(Math.abs(position.getLongitude()) * longitudeFactor);
- }
+ protected Position handlePosition(Position position) {
+ if (latitudeFactor != 0) {
+ position.setLatitude(Math.abs(position.getLatitude()) * latitudeFactor);
}
-
- return msg;
+ if (longitudeFactor != 0) {
+ position.setLongitude(Math.abs(position.getLongitude()) * longitudeFactor);
+ }
+ return position;
}
}