diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 11:35:10 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 11:35:10 +1200 |
commit | 44cdc3449fccd22b21fec1c9a0febea807cc2489 (patch) | |
tree | 4807bb324ad9cde120e66168ddf8b020f80e3efd /src/org/traccar/HemisphereHandler.java | |
parent | ff1afd37323fa634315841cc84917700f969754b (diff) | |
download | trackermap-server-44cdc3449fccd22b21fec1c9a0febea807cc2489.tar.gz trackermap-server-44cdc3449fccd22b21fec1c9a0febea807cc2489.tar.bz2 trackermap-server-44cdc3449fccd22b21fec1c9a0febea807cc2489.zip |
Release incoming reference counted objects
Diffstat (limited to 'src/org/traccar/HemisphereHandler.java')
-rw-r--r-- | src/org/traccar/HemisphereHandler.java | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/org/traccar/HemisphereHandler.java b/src/org/traccar/HemisphereHandler.java index 669ffd36e..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,14 +15,11 @@ */ package org.traccar; -import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import org.traccar.model.Position; -import java.net.SocketAddress; - @ChannelHandler.Sharable -public class HemisphereHandler extends ExtendedObjectDecoder { +public class HemisphereHandler extends BaseDataHandler { private int latitudeFactor; private int longitudeFactor; @@ -47,19 +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; } } |