Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEORADIUS WITHCOORD returns wrong coordinate on multiple results #805

Closed
dittos opened this issue Jun 21, 2018 · 2 comments
Closed

GEORADIUS WITHCOORD returns wrong coordinate on multiple results #805

dittos opened this issue Jun 21, 2018 · 2 comments
Labels
type: bug A general bug
Milestone

Comments

@dittos
Copy link

dittos commented Jun 21, 2018

Bug Report

Current Behavior

GEORADIUS WITHCOORD returns wrong x coordinate starting from the second result.

Input Code

import io.lettuce.core.GeoArgs;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisCommands;

public class LettuceBugDemo {
    public static void main(String[] args) {
        RedisClient client = RedisClient.create();
        StatefulRedisConnection<String, String> connection = client.connect(RedisURI.create("localhost", 6379));
        RedisCommands<String, String> commands = connection.sync();
        commands.del("test");
        commands.geoadd("test", 127.055249, 37.5075175, "a");
        commands.geoadd("test", 127.054251, 37.5053014, "b");
        commands.geoadd("test", 127.0643587, 37.5091197, "c");

        commands.georadius("test", 127.0555244, 37.5076318, 10.0, GeoArgs.Unit.km, GeoArgs.Builder.coordinates())
            .forEach(System.out::println);
    }
}

Prints:

GeoWithin [member=b, distance=null, geohash=null, coordinates=(127.05425351858139, 37.50530199861617)]
GeoWithin [member=a, distance=null, geohash=null, coordinates=(127.05425351858139, 37.50751734490944)]
GeoWithin [member=c, distance=null, geohash=null, coordinates=(127.05425351858139, 37.509119288682136)]

Note that all items have same x coordinate.

Expected behavior/code

Each item should have correct x coordinate.

Environment

  • Lettuce version(s): 5.0.4.RELEASE
  • Redis version: 4.0.9

Possible Solution

GeoWithinListOutput#complete(int) should reset previous x after emitting the result item.

@mp911de
Copy link
Collaborator

mp911de commented Jun 21, 2018

Thanks a lot for reporting the issue.

mp911de added a commit that referenced this issue Jun 21, 2018
…#805

GeoWithinListOutput now resets its longitude (x) coordinate state after completing a GeoWithin item. Previously, the longitude coordinate was never reset and subsequent items used the first reported longitude coordinate which rendered an incorrect result.
mp911de added a commit that referenced this issue Jun 21, 2018
…#805

GeoWithinListOutput now resets its longitude (x) coordinate state after completing a GeoWithin item. Previously, the longitude coordinate was never reset and subsequent items used the first reported longitude coordinate which rendered an incorrect result.
mp911de added a commit that referenced this issue Jun 21, 2018
…#805

GeoWithinListOutput now resets its longitude (x) coordinate state after completing a GeoWithin item. Previously, the longitude coordinate was never reset and subsequent items used the first reported longitude coordinate which rendered an incorrect result.
mp911de added a commit that referenced this issue Jun 21, 2018
…#805

GeoWithinListOutput now resets its longitude (x) coordinate state after completing a GeoWithin item. Previously, the longitude coordinate was never reset and subsequent items used the first reported longitude coordinate which rendered an incorrect result.
@mp911de
Copy link
Collaborator

mp911de commented Jun 21, 2018

That's fixed now.

@mp911de mp911de closed this as completed Jun 21, 2018
mp911de added a commit that referenced this issue Jun 21, 2018
mp911de added a commit that referenced this issue Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants