kb0 / maps_toolkit

Dart library for area, distance, heading measurements
Apache License 2.0
46 stars 17 forks source link

What Unit of Measurement is Being Used for The Area, Square Meters? #20

Open danielverapax opened 2 years ago

gigalala commented 2 years ago

it gives incorrect answer anyways. I compared with online tools and with js package

vkbaloda commented 2 years ago

yes, it's giving wrong for me too. The unit is square meters, it's given in the method comments.

kb0 commented 2 years ago

Yes it's square meters. And polygon must be "closed", i.e. first point = last point, for ex.:

    final p1 = LatLng(45.153474463955796, 39.33852195739747);
    final p2 = LatLng(45.153474463955796, 39.33972358703614);
    final p3 = LatLng(45.15252112936569, 39.33972358703614);
    final p4 = LatLng(45.1525022138355, 39.3385460972786);

    expect(
        SphericalUtil.computeArea([p1, p2, p3, p4, p1]),
        closeTo(9987, 1));