Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

LatLng and LatLngBounds should enforce invariants #3802

Closed

Description

@jfirebaugh

Remove operator bool() from both classes and enforce the following invariants.

  • LatLng constructor throws if any of the following are violated:
    • std::isfinite(latitude)
    • std::isfinite(longitude)
    • -90 <= latitude <= 90
  • LatLngBounds constructor swaps coordinates as necessary to enforce:
    • sw.latitude <= ne.latitude
    • sw.longitude <= ne.longitude

Activity

  1. jfirebaugh commented on Feb 3, 2016

    @jfirebaugh
    ContributorAuthor

    It's useful to have an "empty" state for LatLngBounds: #3803. We can relax the invariant slightly and keep a bool empty() const method around for that.

  2. jfirebaugh commented on Feb 3, 2016

    @jfirebaugh
    ContributorAuthor

    Just discovered an example of how dangerous a non-explicit operator bool can be: currently LatLng(a, b) == LatLng(c, d) is true for any non-NaN a, b, c, d.

  3. added
    Core
    and removed
    Core
    on Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions