{"record":{"id":"952b9bd2bc7004bc","repo":"quarkusio/quarkus","slug":"the-longitude-must-be-in-180-180","errorCode":null,"errorMessage":"The longitude must be in [-180, 180]","messagePattern":"The longitude must be in \\[-180, 180\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoPosition.java","lineNumber":23,"sourceCode":" *\n * The exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following:\n * <ul>\n * <li>Valid longitudes are from -180 to 180 degrees.</li>\n * <li>Valid latitudes are from -85.05112878 to 85.05112878 degrees.</li>\n * </ul>\n */\npublic class GeoPosition {\n\n    public final double longitude;\n    public final double latitude;\n\n    public static GeoPosition of(double longitude, double latitude) {\n        return new GeoPosition(longitude, latitude);\n    }\n\n    private GeoPosition(double longitude, double latitude) {\n        if (longitude < -180 || longitude > 180) {\n            throw new IllegalArgumentException(\"The longitude must be in [-180, 180]\");\n        }\n        if (latitude < -85.05112878 || latitude > 85.05112878) {\n            throw new IllegalArgumentException(\"The latitude must be in [85.05112878, 85.05112878]\");\n        }\n        this.longitude = longitude;\n        this.latitude = latitude;\n    }\n\n    public double longitude() {\n        return longitude;\n    }\n\n    public double latitude() {\n        return latitude;\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":40,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoPosition.java#L5-L40","documentation":"GeoPosition.of(double, double) constructs a geographic coordinate for GEO commands and validates that longitude lies within [-180, 180], the valid WGS-84 range Redis geospatial indexing accepts. Out-of-range longitudes throw this IllegalArgumentException at construction time.","triggerScenarios":"Calling GeoPosition.of(181, 45) or any longitude outside [-180,180] — e.g. swapping arguments and passing a latitude in the longitude slot, or using degrees-minutes-seconds values not converted to decimal degrees.","commonSituations":"Parsing user-supplied or third-party coordinates without range checks; argument-order swaps (lat/lon confusion, the most common geo bug); data from CSV feeds with formatting errors; geocoding services returning unexpected values.","solutions":["Verify you pass (longitude, latitude) in that order — a common mistake is the reverse.","Normalize longitude into [-180,180] before constructing (e.g. ((lon + 180) % 360 + 360) % 360 - 180).","Validate parsed coordinates before calling GeoPosition.of and reject or fix invalid input at the boundary."],"exampleFix":"// before\nGeoPosition pos = GeoPosition.of(48.85, 2.35); // latitude passed as longitude -> throws\n// after\nGeoPosition pos = GeoPosition.of(2.35, 48.85); // (longitude, latitude)","handlingStrategy":"validation","validationCode":"void checkLonLat(double lon, double lat) {\n    if (lon < -180 || lon > 180) throw new IllegalArgumentException(\"longitude out of range: \" + lon);\n    if (lat < -85.05112878 || lat > 85.05112878) throw new IllegalArgumentException(\"latitude out of range: \" + lat);\n}","typeGuard":"boolean isValidLongitude(double lon) { return Double.isFinite(lon) && lon >= -180.0 && lon <= 180.0; }","tryCatchPattern":"try { return GeoPosition.of(lon, lat); } catch (IllegalArgumentException e) { log.warn(\"Invalid coordinate lon={} lat={}\", lon, lat, e); throw e; }","preventionTips":["Remember parameter order is (longitude, latitude) — the most common swap bug.","Validate coordinates at ingestion (parsing, API boundary), not at Redis-call time.","Normalize longitude wrapping across the antimeridian before constructing."],"tags":["redis","geo","coordinate-validation"],"backgroundTag":"invalid-coordinate-range","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}