Commit Graph

113 Commits

Author SHA1 Message Date
Bruno de Oliveira Abinader
e5aa4d70cd [core] Updated Size::isEmpty and TransformState::valid checks 2017-04-10 18:01:28 +03:00
John Firebaugh
16a2839e23 [all] Make LatLng coordinates read-only 2017-04-06 09:22:51 -07:00
John Firebaugh
0314a46ee4 [core] Tighten LatLng and other geo.hpp classes
* Remove LatLng::null and enforce invariants
* Remove unnecessary operator bool()
2017-04-06 09:22:51 -07:00
Bruno de Oliveira Abinader
fc70cbf1e1 [core] Replace MapChange enum with MapObserver 2017-03-15 14:53:32 +02:00
Tobrun
34fef22d95 [core] [android] - allow zooming/scaling to use AnimationOptions (#8181)
[glfw] - allow glfw binding to use AnimationOptions instead of using direction directly
2017-02-28 13:22:47 -05:00
Tobrun
a0992f0550 [core] - allow moveBy to use AnimationOptions
[android] - update jni bindings for moveBy with an interpolator
2017-02-20 16:52:18 -08:00
Konstantin Käfer
e76de05402 [build] move logging to util 2016-11-22 20:58:51 +01:00
Konstantin Käfer
62b56b799a [core] change std::array<uint16_t, 2> to mbgl::Size 2016-10-27 18:30:58 -07:00
Bruno de Oliveira Abinader
2188d68b6c [core] Move TransformState::{un,}project() to Projection 2016-10-19 08:11:41 +03:00
Bruno de Oliveira Abinader
f01a829dc9 [core] Move TransformState::worldSize() to Projection 2016-10-19 08:11:41 +03:00
Bruno de Oliveira Abinader
3a12dd2d4f [core] Skip redundant spherical mercator variable updates in {ease,fly}To 2016-10-19 08:11:41 +03:00
Konstantin Käfer
77e7846756 [core] code style cleanups
- puts function definitions in a namespace ... {} rather than using namespace ...;
- remove trailing whitespace
- add trailing newline
- protect SQL statements from being formatted by clang-format
2016-07-01 12:38:33 +02:00
Bruno de Oliveira Abinader
5792091e9d [core] Added mbgl::util::DEFAULT_TRANSITION_EASE 2016-06-20 13:01:59 +03:00
Bruno de Oliveira Abinader
f751d2c465 [core] Avoid NaNs in TransformState unit conversions
Fix cases where e.g. state has either zero width or height, causing the
unit convertion functions would return NaNs.
2016-05-20 16:18:07 +03:00
Konstantin Käfer
002393bdea [core] remove MockView and View dependency in Transform 2016-05-18 12:07:21 +02:00
John Firebaugh
7e5d0ff49e [core] Rewrite TileCoordinate in terms of geometry.hpp point 2016-05-17 13:20:25 -07:00
Bruno de Oliveira Abinader
c13dd32242 [core] Added Viewport mode
Satisfies embedding platforms that requires the viewport coordinate
systems to be set according to its standards e.g. viewport mirrored
vertically.
2016-05-11 15:48:51 +03:00
John Firebaugh
9330d674a9 [core] Use geometry.hpp's point 2016-05-05 11:30:53 -07:00
John Firebaugh
ce2a06e677 [core] Privatize math.hpp and vec.hpp 2016-05-05 11:16:57 -07:00
Minh Nguyễn
466ed55200 [core, ios, osx] cameraThatFitsCoordinateBounds
Added an API to get a camera that you can pass into -[MGLMapView setCamera:] that fits the given coordinate bounds, by analogy with -[MKMapView regionThatFits:] or -[MKMapView mapRectThatFits:edgePadding:].

Added mbgl::Map::getCameraOptions() for getting the current camera options more conveniently.
2016-04-22 16:39:25 -07:00
Bruno de Oliveira Abinader
f736e46ca4 [core] s/Update::Zoom/Update/RecalculateStyle/ 2016-03-18 01:26:22 +02:00
Bruno de Oliveira Abinader
ac70ada2d3 [core] Check for NaNs in mbgl::util::{min,max,clamp} 2016-03-18 00:53:14 +02:00
Bruno de Oliveira Abinader
fc0a0ef98a [core] Always return wrapped coordinates
This fixes an issue in both iOS and Android when e.g. adding a marker on
both sides of the dateline border in Taveuni island, the marker in one
of the sides would have an out-of-bounds longitude.
2016-03-14 12:16:55 +02:00
Bruno de Oliveira Abinader
78a12d9d47 [core] Ignore shortest path when gesturing in Transform::easeTo
If gesture in progress, we transfer the world rounds from the end
longitude into start, so we can guarantee the "scroll effect" of
rounding the world while assuring the end longitude remains wrapped.
Otherwise, find the shortest path.
2016-03-14 11:51:37 +02:00
Bruno de Oliveira Abinader
b5bb48edaa [core] Simplify LatLng::unwrapForShortestPath usage
Simplify LatLng::{wrap,unwrapForShortestPath} code, avoiding duplicated
code between Transform::{latLngToScreenCoordinate,easeTo,flyTo}.

Added unit tests for camera usage in Transform to detect cases like e.g.
crossing the antimeridian as a shortest path between two coordinates.

Transform::flyTo precision loss to be handled in #4298.
2016-03-14 11:45:31 +02:00
Bruno de Oliveira Abinader
fe7e208b42 [core] Implement LatLng::null() 2016-03-13 21:38:20 +02:00
Bruno de Oliveira Abinader
8e30a4a080 [core] Harden Transform anchor & padding usage
Use optional values for anchor & padding in Map and Transform functions
instead of NaNs. Added unit tests to stress some edge cases.
2016-03-13 21:38:20 +02:00
Bruno de Oliveira Abinader
694a064cdd [core] Fix non-anchored Transform::setAngle
This reverts a line change from b33b2f15, because we explicitely want
the anchor to be invalid.
2016-03-11 16:53:36 +02:00
Bruno de Oliveira Abinader
f73beb5913 [core] Fix screen coordinates when crossing the antimeridian (#2)
Added missing case. Really fixes #4155 this time.
2016-03-11 12:34:21 +02:00
Bruno de Oliveira Abinader
1a4b8f3e2f [core] Fix screen coordinates when crossing the antimeridian
If the center and point coordinates are not in the same side of the
antimeridian, we need to unwrap the point longitude to make sure
it can still be seen from the visible side of the antimeridian that is
opposite to the center side.

Fixes #4155.
2016-03-10 14:00:42 +02:00
Bruno de Oliveira Abinader
7dde622db1 [core] Extra checks in Transform 2016-03-10 03:36:47 +02:00
Bruno de Oliveira Abinader
b33b2f1515 [core] Check for NaNs in EdgeInsets 2016-03-10 03:36:46 +02:00
Bruno de Oliveira Abinader
e8d1276bb1 [core] Added Transform::getScreenCoordinate 2016-03-10 03:36:46 +02:00
Bruno de Oliveira Abinader
d300f341bc [core] Remove _validPoint from Transform code
vec2<T>::operator bool() checks for NaNs already.
2016-03-10 03:36:46 +02:00
Bruno de Oliveira Abinader
026b6d4c01 [core] Coordinate wrapping fixes
- Make returning LatLngs unwrapped by default.
- PointAnnotation and ShapeAnnotation are always wrapped so they can be
  selected via intersection from the visible tile boundaries.
- Fixes LatLng::wrap() calculation.
- Fixes LatLng::unwrapForShortestPath() calculation.

The new unwrapForShortestPath algorithm unwraps the start coordinate
either forwards or backwards depending on the end coordinate value, so
we can always cross the antimeridian when needed and still obtain a
wrapped end coordinate in the end.

Fixes #4214.
2016-03-10 03:36:45 +02:00
Bruno de Oliveira Abinader
c6757b9a9b [core] Added DEGREES_MAX as constant value 2016-03-01 20:58:54 +00:00
Bruno de Oliveira Abinader
6e6d91478e [core] Cleared TileCoordinate from Painter 2016-03-01 20:58:54 +00:00
Bruno de Oliveira Abinader
abe3f9ce7a [core] Moved wrapping to LatLng scope
Fixes a precision loss when converting unwrapped LatLngs.
2016-03-01 20:58:54 +00:00
Bruno de Oliveira Abinader
4994b3dc57 [core] PrecisionPoint is now ScreenCoordinate 2016-03-01 20:58:54 +00:00
Bruno de Oliveira Abinader
411a562061 [core] Enforce constants usage
Use 'LATITUDE_MAX', 'LONGITUDE_MAX', 'DEG2RAD' and 'RAD2DEG' whenever
possible.
2016-03-01 20:58:54 +00:00
Minh Nguyễn
bd59ab9a52 [core, ios, osx] Only constrain after adding to a window
Introduced a setter/getter for constrain mode. On iOS and OS X, the zoom level inspectable causes the zoom level to be set independently from the longitude and latitude. Thus, the latitude inspectable had no effect because the latitude was constrained to 0 at z0. Temporarily removing the heightwise constraint allows the map to center on the intended location before zooming, which is the usual case for storyboards and XIBs. On iOS, the only guarantee we have timing-wise is that all the inspectables are applied after initialization but before the view is added to a window. So we reimpose the heightwise constraint as soon as the view is added to a window, that is, before the user has a chance to pan the map out of bounds.

Fixes #3868.
2016-02-10 15:15:29 -08:00
Ansis Brammanis
1644234179 [core] add setMaxZoom, setMinZoom
also change the default maxZoom to 20 to match -js.
2016-01-28 15:10:01 -08:00
Minh Nguyễn
8a23bdcd01 [core, ios, osx] Tilt around visual center point
The tilt gesture on both iOS and OS X now respects the content insets. On iOS, in user tracking mode, it additionally respects the user dot’s position if it’s aligned to the top or bottom of the view.
2016-01-26 18:49:01 -08:00
Bruno de Oliveira Abinader
2f86467586 Cleanup std::chrono usage
Use mbgl::Duration and mbgl::{,Milli}Seconds whenever possible.
2016-01-25 15:11:18 +02:00
Minh Nguyễn
8dfba0ef0b [ios] Flip points, not edge insets 2016-01-18 16:54:58 -08:00
Minh Nguyễn
eee4764ed7 [core] Reformulated setLatLng() based on CameraOptions
This version of setLatLng() can be expressed by constraining the viewport to a 0×0 viewport around the passed-in point.
2016-01-18 16:54:58 -08:00
Minh Nguyễn
47b69100f9 [core, ios, osx, android, glfw] Flipped origin of Map::latLngForPixel(), Map::pixelForLatLng()
Map and Transform methods assume an origin at the top-left corner of the view, like iOS, Android, and GLFW but unlike OS X. Transform is responsible for flipping coordinates between the top-left origin of Map and the bottom-left origin of TransformState.

Fixes #3574.
2016-01-18 16:54:58 -08:00
Minh Nguyễn
bf87eaa7b8 [core, osx] Added optional padding to convenience methods
Methods that offer a convenient way to jump or ease now accept an optional padding parameter. MGLMapView specifies the padding to ensure that keyboard-based zooming and rotation respects the toolbar.
2016-01-18 16:54:58 -08:00
Minh Nguyễn
143f8a7817 [core] Added padding option to CameraOptions
Moved EdgeInsets to geo.hpp so CameraOptions and Transform can refer to it. Added a padding option to CameraOptions that alters the frame of reference for the center option. Added optional padding parameters to LatLng getters and setters.

Working towards #2600.
2016-01-18 16:54:57 -08:00
Thiago Marcos P. Santos
f9574e350c [core] Fix crash on transitionFrameFn callback
This is a tricky one:

We are storing a lambda at the member variable `transitionFrameFn` and
capturing `this` at this lambda function.

At some point when running the callback, we set `transitionFrameFn` to
`nullptr`, effectively destroying the callback that is being executed.

After this point, `this` is no longer valid, as the memory gets
cleared and it might point to the correct location (or not). That
is why it works on some compilers but not on g++ 5.3.1. Touching
any `this->[smth]` is undefined after that.

The fix is just move `transitionFrameFn = nullptr` to the last
thing we do on the callback. This behaves similarly to calling
`delete this` on a class method.
2016-01-14 18:59:38 +02:00