{"record":{"id":"702afe41a1ea6aa6","repo":"microg/GmsCore","slug":"latitude-of-northeast-corner-must-not-be-lower-tha","errorCode":null,"errorMessage":"latitude of northeast corner must not be lower than latitude of southwest corner","messagePattern":"latitude of northeast corner must not be lower than latitude of southwest corner","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-maps/src/main/java/com/google/android/gms/maps/model/LatLngBounds.java","lineNumber":70,"sourceCode":"     * Creates a new bounds based on a southwest and a northeast corner.\n     * <p/>\n     * The bounds conceptually includes all points where:\n     * <ul>\n     * <li>the latitude is in the range [northeast.latitude, southwest.latitude];</li>\n     * <li>the longitude is in the range [southwest.longtitude, northeast.longitude]\n     * if southwest.longtitude ≤ northeast.longitude; and</li>\n     * <li>the longitude is in the range [southwest.longitude, 180) ∪ [-180, northeast.longitude]\n     * if southwest.longtitude > northeast.longitude.</li>\n     * </ul>\n     *\n     * @param southwest southwest corner\n     * @param northeast northeast corner\n     * @throws IllegalArgumentException if the latitude of the northeast corner is below the\n     *                                  latitude of the southwest corner.\n     */\n    public LatLngBounds(LatLng southwest, LatLng northeast) throws IllegalArgumentException {\n        if (northeast.latitude < southwest.latitude)\n            throw new IllegalArgumentException(\"latitude of northeast corner must not be\" +\n                    \" lower than latitude of southwest corner\");\n        this.southwest = southwest;\n        this.northeast = northeast;\n    }\n\n    /**\n     * Creates a new builder.\n     */\n    public Builder builder() {\n        return new Builder();\n    }\n\n    /**\n     * Returns whether this contains the given {@link LatLng}.\n     *\n     * @param point the {@link LatLng} to test\n     * @return {@code true} if this contains the given point; {@code false} if not.\n     */","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-maps/src/main/java/com/google/android/gms/maps/model/LatLngBounds.java#L52-L88","documentation":"The LatLngBounds(southwest, northeast) constructor throws IllegalArgumentException when northeast.latitude is lower than southwest.latitude. Bounds must be a valid rectangle with the northeast corner geographically north of (or equal to) the southwest corner. Longitude is not validated the same way (it may wrap), but the latitude ordering is mandatory.","triggerScenarios":"Calling new LatLngBounds(sw, ne) where ne.latitude < sw.latitude — e.g. corners computed independently from two arbitrary points, coordinates swapped, or bounds accumulated by naive min/max on mismatched axes.","commonSituations":"Building bounds from two user-selected points without ordering them (the user may drag a selection 'south-up'); deserializing bounds from an API where corners arrive unordered; computing a bounds from a path in the wrong order; using include() instead avoids this entirely.","solutions":["Normalize the corners before constructing: sw = new LatLng(min(lat1,lat2), ...), ne = new LatLng(max(lat1,lat2), ...).","Prefer LatLngBounds.builder() with include(point) for each point — it maintains correct ordering automatically.","When receiving bounds from external input, validate/swap corners: if (ne.latitude < sw.latitude) swap the latitudes."],"exampleFix":"// before\nLatLngBounds bounds = new LatLngBounds(pointA, pointB); // may be unordered\n\n// after\nLatLngBounds bounds = new LatLngBounds.Builder()\n    .include(pointA)\n    .include(pointB)\n    .build();","handlingStrategy":"validation","validationCode":"double sLat = Math.min(a.latitude, b.latitude);\ndouble nLat = Math.max(a.latitude, b.latitude);\n// build corners from ordered latitudes","typeGuard":"boolean isOrdered(LatLng sw, LatLng ne) { return ne.latitude >= sw.latitude; }","tryCatchPattern":"try {\n    LatLngBounds b = new LatLngBounds(sw, ne);\n} catch (IllegalArgumentException e) {\n    LatLngBounds b = new LatLngBounds(\n        new LatLng(Math.min(sw.latitude, ne.latitude), sw.longitude),\n        new LatLng(Math.max(sw.latitude, ne.latitude), ne.longitude));\n}","preventionTips":["Use LatLngBounds.Builder().include(point) instead of raw corner construction.","Normalize/swap corners from user selections or external data before constructing.","Unit-test bounds helpers with points given in both orders."],"tags":["maps","android","latlng","bounds","range-check"],"backgroundTag":"invalid-argument-value","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}