diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-01-20 19:00:40 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-01-20 19:00:40 +1300 |
commit | bb94a3d09a78530807cab31d2b0cee829ff084d4 (patch) | |
tree | 0d833ed54a9ed665710fb4e91204072a527d9c10 | |
parent | 44c0dc492306bbd8c0f8cf8a50aa8cba70749602 (diff) | |
download | trackermap-server-bb94a3d09a78530807cab31d2b0cee829ff084d4.tar.gz trackermap-server-bb94a3d09a78530807cab31d2b0cee829ff084d4.tar.bz2 trackermap-server-bb94a3d09a78530807cab31d2b0cee829ff084d4.zip |
Fix list geocoding issue (fix #520)
-rw-r--r-- | src/org/traccar/ReverseGeocoderHandler.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/org/traccar/ReverseGeocoderHandler.java b/src/org/traccar/ReverseGeocoderHandler.java index 74dfd10e9..8bdd7ebfc 100644 --- a/src/org/traccar/ReverseGeocoderHandler.java +++ b/src/org/traccar/ReverseGeocoderHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2014 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package org.traccar; +import java.util.List; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; @@ -22,15 +23,9 @@ import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; import org.traccar.geocode.ReverseGeocoder; import org.traccar.model.Position; -/** - * Reverse geocoding channel event handler - */ public class ReverseGeocoderHandler extends OneToOneDecoder { - /** - * Geocoder object - */ - private ReverseGeocoder geocoder; + private final ReverseGeocoder geocoder; public ReverseGeocoderHandler(ReverseGeocoder geocoder) { this.geocoder = geocoder; @@ -40,12 +35,18 @@ public class ReverseGeocoderHandler extends OneToOneDecoder { protected Object decode( ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { - - if (msg instanceof Position) { - Position position = (Position) msg; - if (geocoder != null) { + + if (geocoder != null) { + if (msg instanceof Position) { + Position position = (Position) msg; position.setAddress(geocoder.getAddress( position.getLatitude(), position.getLongitude())); + } else if (msg instanceof List) { + List<Position> positions = (List<Position>) msg; + for (Position position : positions) { + position.setAddress(geocoder.getAddress( + position.getLatitude(), position.getLongitude())); + } } } |