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

refs #893 #992: point annotations API #1018

Closed
wants to merge 17 commits into from
Closed

Conversation

incanus
Copy link
Contributor

@incanus incanus commented Mar 17, 2015

This is Phase One of the point annotations API — adding, removing, querying, and setting sprite-based symbology for point annotations.

@jfirebaugh If you have some time would you mind sharing some 👀 — especially since this relates to the GeometryTile refactor.

Two things I want to do to this next, but input is welcome:

  • Get rid of the pointer casts per fbd5511#commitcomment-10224463.
  • See about getting rid of LiveTileParser entirely and defaulting to TileParser. This was created in order to get a createBucket() and address troubles with the getLayer() API, but I think that's obsolete now.

@incanus incanus added this to the iOS Beta 1 milestone Mar 17, 2015

namespace mbgl {

class LiveTileFeature : public GeometryTileFeature, private util::noncopyable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These classes are derived from util::noncopyable already so you don't need to re-inherit it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto features_it = annotation->tileFeatures.find(tile_it.first);
if (features_it != annotation->tileFeatures.end()) {
auto layer = tile_it.second.second->getLayer(util::ANNOTATIONS_POINTS_LAYER_ID);
auto liveLayer = std::static_pointer_cast<LiveTileLayer>(layer);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting this one now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public:
TileParser(const std::string& rawData,
TileParser(const GeometryTile* geometryTile,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const GeometryTile&

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -37,6 +37,9 @@ class GlyphAtlas;
class SpriteAtlas;
class LineAtlas;
class Environment;
class AnnotationManager;

typedef std::vector<LatLng> AnnotationSegment;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be used by this header; should move to annotation.hpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning here is because the shapes API will have it; you pass vectors of AnnotationSegment objects to represent lines in a shape.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifndef MBGL_MAP_ANNOTATIONS
#define MBGL_MAP_ANNOTATIONS

#include <mbgl/map/map.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a forward declaration instead of an include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to not seeing AnnotationSegment, and that can't be forward declared because it is used in getPoint(). That method can't be moved inside of annotation.cpp because then you get a redefinition error between the forward declaration of AnnotationSegment and the one brought into annotation.cpp with #include <mbgl/map/map.hpp>. This went really deep and doing it like this seemed the only way to keep things happy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying problem is the cyclic dependency between AnnotationManager and Map. It looks like you can break the cycle by removing Map& map from AnnotationManager and passing the max zoom to AnnotationManager::getAnnotationsInBounds and AnnotationManager::addPointAnnotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird from an API point of view — clients like Cocoa would have to query, then pass the max zoom, when it doesn't appear to need to be an argument of querying bounds for annotations (they are independent of zoom and an implementation detail).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought clients would use the API provided by Map?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh, got it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@incanus
Copy link
Contributor Author

incanus commented Mar 18, 2015

#1021

@incanus incanus closed this Mar 18, 2015
@incanus incanus deleted the point-annotations branch March 18, 2015 03:08
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants