Skip to content

Commit

Permalink
rename DataSource -> TileSource
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanetzek committed Oct 20, 2016
1 parent 22732dd commit 7e5e6d6
Show file tree
Hide file tree
Showing 37 changed files with 209 additions and 209 deletions.
18 changes: 9 additions & 9 deletions android/tangram/jni/jniExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,29 @@ extern "C" {
}
}

JNIEXPORT jlong JNICALL Java_com_mapzen_tangram_MapController_nativeAddDataSource(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jstring name) {
JNIEXPORT jlong JNICALL Java_com_mapzen_tangram_MapController_nativeAddTileSource(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jstring name) {
assert(mapPtr > 0);
auto map = reinterpret_cast<Tangram::Map*>(mapPtr);
auto sourceName = stringFromJString(jniEnv, name);
auto source = std::shared_ptr<Tangram::DataSource>(new Tangram::ClientGeoJsonSource(sourceName, ""));
map->addDataSource(source);
auto source = std::shared_ptr<Tangram::TileSource>(new Tangram::ClientGeoJsonSource(sourceName, ""));
map->addTileSource(source);
return reinterpret_cast<jlong>(source.get());
}

JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeRemoveDataSource(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jlong sourcePtr) {
JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeRemoveTileSource(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jlong sourcePtr) {
assert(mapPtr > 0);
auto map = reinterpret_cast<Tangram::Map*>(mapPtr);
assert(sourcePtr > 0);
auto source = reinterpret_cast<Tangram::DataSource*>(sourcePtr);
map->removeDataSource(*source);
auto source = reinterpret_cast<Tangram::TileSource*>(sourcePtr);
map->removeTileSource(*source);
}

JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeClearDataSource(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jlong sourcePtr) {
JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeClearTileSource(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jlong sourcePtr) {
assert(mapPtr > 0);
auto map = reinterpret_cast<Tangram::Map*>(mapPtr);
assert(sourcePtr > 0);
auto source = reinterpret_cast<Tangram::DataSource*>(sourcePtr);
map->clearDataSource(*source, true, true);
auto source = reinterpret_cast<Tangram::TileSource*>(sourcePtr);
map->clearTileSource(*source, true, true);
}

JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeAddFeature(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jlong sourcePtr,
Expand Down
30 changes: 15 additions & 15 deletions android/tangram/src/com/mapzen/tangram/MapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ void dispose() {
public void run() {
// Dispose each data sources by first removing it from the HashMap values and then
// calling remove(), so that we don't improperly modify the HashMap while iterating.
for (Iterator<MapData> it = clientDataSources.values().iterator(); it.hasNext();) {
for (Iterator<MapData> it = clientTileSources.values().iterator(); it.hasNext();) {
MapData mapData = it.next();
it.remove();
mapData.remove();
}
nativeDispose(mapPointer);
mapPointer = 0;
clientDataSources.clear();
clientTileSources.clear();
}
});
}
Expand Down Expand Up @@ -448,17 +448,17 @@ public PointF lngLatToScreenPosition(LngLat lngLat) {
* object will be returned.
*/
public MapData addDataLayer(String name) {
MapData mapData = clientDataSources.get(name);
MapData mapData = clientTileSources.get(name);
if (mapData != null) {
return mapData;
}
checkPointer(mapPointer);
long pointer = nativeAddDataSource(mapPointer, name);
long pointer = nativeAddTileSource(mapPointer, name);
if (pointer <= 0) {
throw new RuntimeException("Unable to create new data source");
}
mapData = new MapData(name, pointer, this);
clientDataSources.put(name, mapData);
clientTileSources.put(name, mapData);
return mapData;
}

Expand All @@ -467,10 +467,10 @@ public MapData addDataLayer(String name) {
* @param mapData The {@code MapData} to remove
*/
void removeDataLayer(MapData mapData) {
clientDataSources.remove(mapData.name);
clientTileSources.remove(mapData.name);
checkPointer(mapPointer);
checkPointer(mapData.pointer);
nativeRemoveDataSource(mapPointer, mapData.pointer);
nativeRemoveTileSource(mapPointer, mapData.pointer);
}

/**
Expand Down Expand Up @@ -707,16 +707,16 @@ public void useCachedGlState(boolean use) {
// Package private methods
// =======================

void removeDataSource(long sourcePtr) {
void removeTileSource(long sourcePtr) {
checkPointer(mapPointer);
checkPointer(sourcePtr);
nativeRemoveDataSource(mapPointer, sourcePtr);
nativeRemoveTileSource(mapPointer, sourcePtr);
}

void clearDataSource(long sourcePtr) {
void clearTileSource(long sourcePtr) {
checkPointer(mapPointer);
checkPointer(sourcePtr);
nativeClearDataSource(mapPointer, sourcePtr);
nativeClearTileSource(mapPointer, sourcePtr);
}

void addFeature(long sourcePtr, double[] coordinates, int[] rings, String[] properties) {
Expand Down Expand Up @@ -784,9 +784,9 @@ void checkPointer(long ptr) {
private native void nativeOnUrlSuccess(byte[] rawDataBytes, long callbackPtr);
private native void nativeOnUrlFailure(long callbackPtr);

synchronized native long nativeAddDataSource(long mapPtr, String name);
synchronized native void nativeRemoveDataSource(long mapPtr, long sourcePtr);
synchronized native void nativeClearDataSource(long mapPtr, long sourcePtr);
synchronized native long nativeAddTileSource(long mapPtr, String name);
synchronized native void nativeRemoveTileSource(long mapPtr, long sourcePtr);
synchronized native void nativeClearTileSource(long mapPtr, long sourcePtr);
synchronized native void nativeAddFeature(long mapPtr, long sourcePtr, double[] coordinates, int[] rings, String[] properties);
synchronized native void nativeAddGeoJson(long mapPtr, long sourcePtr, String geoJson);

Expand All @@ -808,7 +808,7 @@ void checkPointer(long ptr) {
private ViewCompleteListener viewCompleteListener;
private FrameCaptureCallback frameCaptureCallback;
private boolean frameCaptureAwaitCompleteView;
private Map<String, MapData> clientDataSources = new HashMap<>();
private Map<String, MapData> clientTileSources = new HashMap<>();

// GLSurfaceView.Renderer methods
// ==============================
Expand Down
2 changes: 1 addition & 1 deletion android/tangram/src/com/mapzen/tangram/MapData.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public MapData addGeoJson(String data) {
* @return This object, for chaining.
*/
public MapData clear() {
map.clearDataSource(pointer);
map.clearTileSource(pointer);
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions bench/src/tileLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "gl.h"
#include "platform.h"
#include "log.h"
#include "data/dataSource.h"
#include "data/tileSource.h"
#include "scene/sceneLoader.h"
#include "scene/scene.h"
#include "style/style.h"
Expand Down Expand Up @@ -30,7 +30,7 @@ struct TestContext {
std::shared_ptr<Scene> scene;
StyleContext styleContext;

std::shared_ptr<DataSource> source;
std::shared_ptr<TileSource> source;

std::vector<char> rawTileData;

Expand All @@ -56,7 +56,7 @@ struct TestContext {
styleContext.initFunctions(*scene);
styleContext.setKeywordZoom(0);

source = *scene->dataSources().begin();
source = *scene->tileSources().begin();
tileBuilder = std::make_unique<TileBuilder>(scene);
}

Expand All @@ -78,7 +78,7 @@ struct TestContext {

void parseTile() {
Tile tile({0,0,10,10,0}, s_projection);
source = *scene->dataSources().begin();
source = *scene->tileSources().begin();
auto task = source->createTask(tile.getID());
auto& t = dynamic_cast<DownloadTileTask&>(*task);
t.rawTileData = std::make_shared<std::vector<char>>(rawTileData);
Expand Down
4 changes: 2 additions & 2 deletions core/src/data/clientGeoJsonSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Point transformPoint(geojsonvt::TilePoint pt) {
// TODO: pass scene's resourcePath to constructor to be used with `stringFromFile`
ClientGeoJsonSource::ClientGeoJsonSource(const std::string& _name, const std::string& _url,
int32_t _minDisplayZoom, int32_t _maxDisplayZoom, int32_t _maxZoom)
: DataSource(_name, nullptr, _minDisplayZoom, _maxDisplayZoom, _maxZoom) {
: TileSource(_name, nullptr, _minDisplayZoom, _maxDisplayZoom, _maxZoom) {

// TODO: handle network url for client datasource data
// TODO: generic uri handling
Expand Down Expand Up @@ -87,7 +87,7 @@ void ClientGeoJsonSource::loadTileData(std::shared_ptr<TileTask> _task, TileTask
}

// Load subsources
DataSource::loadTileData(_task, _cb);
TileSource::loadTileData(_task, _cb);
}

void ClientGeoJsonSource::clearData() {
Expand Down
4 changes: 2 additions & 2 deletions core/src/data/clientGeoJsonSource.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "dataSource.h"
#include "tileSource.h"
#include "util/types.h"

#include <mutex>
Expand All @@ -19,7 +19,7 @@ using GeoJSONVT = mapbox::util::geojsonvt::GeoJSONVT;

struct Properties;

class ClientGeoJsonSource : public DataSource {
class ClientGeoJsonSource : public TileSource {

public:

Expand Down
6 changes: 3 additions & 3 deletions core/src/data/geoJsonSource.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "dataSource.h"
#include "tileSource.h"

namespace Tangram {

class GeoJsonSource: public DataSource {
class GeoJsonSource: public TileSource {

public:
using DataSource::DataSource;
using TileSource::TileSource;

protected:

Expand Down
4 changes: 2 additions & 2 deletions core/src/data/memoryCacheDataSource.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "data/dataSource.h"
#include "data/tileSource.h"

namespace Tangram {

class MemoryCacheDataSource : public RawDataSource {
class MemoryCacheDataSource : public TileSource::DataSource {
public:

MemoryCacheDataSource();
Expand Down
6 changes: 3 additions & 3 deletions core/src/data/mvtSource.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "dataSource.h"
#include "tileSource.h"

namespace Tangram {

class MVTSource : public DataSource {
class MVTSource : public TileSource {

public:
using DataSource::DataSource;
using TileSource::TileSource;

protected:

Expand Down
4 changes: 2 additions & 2 deletions core/src/data/networkDataSource.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "data/dataSource.h"
#include "data/tileSource.h"

namespace Tangram {

class NetworkDataSource : public RawDataSource {
class NetworkDataSource : public TileSource::DataSource {
public:
NetworkDataSource(const std::string& _urlTemplate)
: m_urlTemplate(_urlTemplate) {}
Expand Down
8 changes: 4 additions & 4 deletions core/src/data/rasterSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Tangram {

class RasterTileTask : public DownloadTileTask {
public:
RasterTileTask(TileID& _tileId, std::shared_ptr<DataSource> _source, int _subTask)
RasterTileTask(TileID& _tileId, std::shared_ptr<TileSource> _source, int _subTask)
: DownloadTileTask(_tileId, _source, _subTask) {}

std::shared_ptr<Texture> m_texture;
Expand Down Expand Up @@ -69,10 +69,10 @@ class RasterTileTask : public DownloadTileTask {
};


RasterSource::RasterSource(const std::string& _name, std::unique_ptr<RawDataSource> _sources,
RasterSource::RasterSource(const std::string& _name, std::unique_ptr<DataSource> _sources,
int32_t _minDisplayZoom, int32_t _maxDisplayZoom, int32_t _maxZoom,
TextureOptions _options, bool _genMipmap)
: DataSource(_name, std::move(_sources), _minDisplayZoom, _maxDisplayZoom, _maxZoom),
: TileSource(_name, std::move(_sources), _minDisplayZoom, _maxDisplayZoom, _maxZoom),
m_texOptions(_options),
m_genMipmap(_genMipmap) {

Expand Down Expand Up @@ -104,7 +104,7 @@ void RasterSource::loadTileData(std::shared_ptr<TileTask> _task, TileTaskCb _cb)
_cb.func(_task);
}};

DataSource::loadTileData(_task, cb);
TileSource::loadTileData(_task, cb);
}

std::shared_ptr<TileData> RasterSource::parse(const TileTask& _task, const MapProjection& _projection) const {
Expand Down
6 changes: 3 additions & 3 deletions core/src/data/rasterSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <tile/tileTask.h>
#include "tile/tileHash.h"
#include "dataSource.h"
#include "tileSource.h"
#include "gl/texture.h"

#include <functional>
Expand All @@ -14,7 +14,7 @@ namespace Tangram {

class RasterTileTask;

class RasterSource : public DataSource {
class RasterSource : public TileSource {

TextureOptions m_texOptions;
bool m_genMipmap;
Expand All @@ -29,7 +29,7 @@ class RasterSource : public DataSource {

public:

RasterSource(const std::string& _name, std::unique_ptr<RawDataSource> _sources,
RasterSource(const std::string& _name, std::unique_ptr<DataSource> _sources,
int32_t _minDisplayZoom, int32_t _maxDisplayZoom, int32_t _maxZoom,
TextureOptions _options, bool genMipmap = false);

Expand Down
Loading

0 comments on commit 7e5e6d6

Please sign in to comment.