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

Commit

Permalink
#877 - Removing Sample Location data model and access methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Mar 3, 2015
1 parent f3895e4 commit aed532b
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 92 deletions.
4 changes: 0 additions & 4 deletions include/mbgl/ios/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@
/** Resets the map rotation to a northern heading. */
- (void)resetNorth;

# pragma mark - Sample Locations
- (NSArray *) getSampleLoctions;
- (NSArray *) getSampleLoctionsScreenCoordinatesConvertedFromView:(UIView *)view;

#pragma mark - Converting Map Coordinates

/** @name Converting Map Coordinates */
Expand Down
6 changes: 1 addition & 5 deletions include/mbgl/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ class Map : private util::noncopyable {
void stopScaling();
double getMinZoom() const;
double getMaxZoom() const;

// Sample Locations
std::array<LatLng, 4> getSampleLocations() const;
std::array<mbgl::vec2<double>, 4> getSampleLocationsScreenCoordinates() const;


// Rotation
void rotateBy(double sx, double sy, double ex, double ey, std::chrono::steady_clock::duration duration = std::chrono::steady_clock::duration::zero());
void setBearing(double degrees, std::chrono::steady_clock::duration duration = std::chrono::steady_clock::duration::zero());
Expand Down
5 changes: 0 additions & 5 deletions include/mbgl/map/transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ class Transform : private util::noncopyable {
void stopScaling();
double getMinZoom() const;
double getMaxZoom() const;

// Sample Locations
std::array<LatLng, 4> getSampleLocations() const;
std::array<mbgl::vec2<double>, 4> getSampleLocationsScreenCoordinates() const;

// Angle
void rotateBy(double sx, double sy, double ex, double ey, std::chrono::steady_clock::duration duration = std::chrono::steady_clock::duration::zero());
Expand Down Expand Up @@ -77,7 +73,6 @@ class Transform : private util::noncopyable {
void _clearRotating();
void _clearScaling();

void updateSampleLocationScreenCoordinates();
void constrain(double& scale, double& y) const;

private:
Expand Down
6 changes: 1 addition & 5 deletions include/mbgl/map/transform_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class TransformState {

// Changing
bool isChanging() const;

// Sample Location Data
std::array<LatLng, 4> getSampleLocations() const;
std::array<mbgl::vec2<double>, 4> getSampleLocationsScreenCoordinates() const;


private:
double pixel_x() const;
double pixel_y() const;
Expand Down
32 changes: 0 additions & 32 deletions platform/ios/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -917,38 +917,6 @@ - (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude
return mbglMap->getMetersPerPixelAtLatitude(latitude, self.zoomLevel);
}

# pragma mark - Sample Locations
- (NSArray *) getSampleLoctions {
NSMutableArray* results = [[NSMutableArray alloc] init];

std::array<mbgl::LatLng, 4> locs = mbglMap->getSampleLocations();

for (unsigned long lc = 0; lc < locs.size(); lc++) {
NSString *latLon = [NSString stringWithFormat:@"%f,%f", locs[lc].latitude, locs[lc].longitude];
[results addObject:latLon];
}

return results;
}

- (NSArray *) getSampleLoctionsScreenCoordinatesConvertedFromView:(UIView *)view {

NSMutableArray* results = [[NSMutableArray alloc] init];

std::array<mbgl::vec2<double>, 4> locs = mbglMap->getSampleLocationsScreenCoordinates();
for (unsigned long lc = 0; lc < locs.size(); lc++) {
mbgl::vec2<double> pixel = locs[lc];
// flip y coordinate for iOS view origin in top left
//
pixel.y = self.bounds.size.height - pixel.y;

[results addObject:[NSValue valueWithCGPoint:[self convertPoint:CGPointMake(pixel.x, pixel.y) toView:view]]];
}

return results;
}


#pragma mark - Styling -

- (NSDictionary *)getRawStyle
Expand Down
9 changes: 0 additions & 9 deletions src/mbgl/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,6 @@ double Map::getMaxZoom() const {
return transform.getMaxZoom();
}

#pragma mark - Sample Locations
std::array<LatLng, 4> Map::getSampleLocations() const {
return transform.getSampleLocations();
}

std::array<mbgl::vec2<double>, 4> Map::getSampleLocationsScreenCoordinates() const {
return transform.getSampleLocationsScreenCoordinates();
}

#pragma mark - Rotation

void Map::rotateBy(double sx, double sy, double ex, double ey, std::chrono::steady_clock::duration duration) {
Expand Down
22 changes: 0 additions & 22 deletions src/mbgl/map/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ void Transform::_moveBy(const double dx, const double dy, const std::chrono::ste
view.notifyMapChange(duration != std::chrono::steady_clock::duration::zero() ?
MapChangeRegionWillChangeAnimated :
MapChangeRegionWillChange);


updateSampleLocationScreenCoordinates();

final.x = current.x + std::cos(current.angle) * dx + std::sin(current.angle) * dy;
final.y = current.y + std::cos(current.angle) * dy + std::sin(-current.angle) * dx;
Expand Down Expand Up @@ -210,14 +207,6 @@ double Transform::getMaxZoom() const {
return std::log2(max_scale);
}

std::array<LatLng, 4> Transform::getSampleLocations() const {
return current.getSampleLocations();
}

std::array<mbgl::vec2<double>, 4> Transform::getSampleLocationsScreenCoordinates() const {
return current.getSampleLocationsScreenCoordinates();
}

void Transform::_clearScaling() {
// This is only called internally, so we don't need a lock here.

Expand Down Expand Up @@ -300,17 +289,6 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl
duration);
}

#pragma mark - Sample Location Screen Coordinates
void Transform::updateSampleLocationScreenCoordinates() {

std::array<LatLng, 4> locs = current.getSampleLocations();

for (unsigned long lc = 0; lc < locs.size(); lc++) {
mbgl::vec2<double> pixel = current.pixelForLatLng(locs[lc]);
current.sampleLocationsScreenCooridnates[lc] = pixel;
}
}

#pragma mark - Constraints

void Transform::constrain(double& scale, double& y) const {
Expand Down
10 changes: 0 additions & 10 deletions src/mbgl/map/transform_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,6 @@ bool TransformState::isChanging() const {
return rotating || scaling || panning;
}

#pragma mark - Sample Locations

std::array<LatLng, 4> TransformState::getSampleLocations() const {
return sampleLocations;
}

std::array<mbgl::vec2<double>, 4> TransformState::getSampleLocationsScreenCoordinates() const {
return sampleLocationsScreenCooridnates;
}

#pragma mark - (private helper functions)


Expand Down

0 comments on commit aed532b

Please sign in to comment.