This repository has been archived by the owner on May 28, 2019. It is now read-only.
Tilestream plugin #30
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c1a51c7
add the tile stream plugin to the isc viewer app
bwyss d26fe3b
syntax issue
bwyss 1d0f719
typo
bwyss 3a23f33
change location of the tilestream plugin
bwyss 585014d
update tilestream plugin
bwyss 87caf06
remove the isc app plugins directory
bwyss 760dcd7
name the layers
bwyss 518bda6
Merge branch 'master' into tilestream_plugin
bwyss eacdb2e
update the install script with branch version name
bwyss 8f8f76c
update the gxp.js minify file with gxp tilestream source plugin
bwyss 2e1dc59
update the install script to include the gxp tilestream source into l…
bwyss 5eeef7a
update install script to add tilestream source only when it is not al…
bwyss 4285726
update gxp.js with better layer source name for tile stream layers
bwyss 120275c
add a description of the tilestream plugin
bwyss 3b5bc49
update the install script with ref to master
bwyss 424e9da
add small comment
bwyss File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
oq-ui-client2/src/gxp/script/plugins/TileStreamSource.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/** | ||
|
||
This plugin is based on the MapBoxSource plugin. It was created in order to | ||
render tiles served from a TileStream server. The key difference to note is | ||
that this plugin uses OpenLayers.Layer.XYZ while the MapBox plugin uses TMS. | ||
We are using OpenLayers.Layer.XYZ because TileStream serves its tiles in | ||
version 2 which is not compatible with TMS. | ||
|
||
copyright (c) 2008-2011 The Open Planning Project | ||
* | ||
* Published under the GPL license. | ||
* See https://github.com/opengeo/gxp/raw/master/license.txt for the full text | ||
* of the license. | ||
*/ | ||
|
||
/** | ||
* @requires plugins/LayerSource.js | ||
* @requires OpenLayers/Layer/TMS.js | ||
*/ | ||
|
||
/** api: (define) | ||
* module = gxp.plugins | ||
* class = MapBoxSource | ||
*/ | ||
|
||
/** api: (extends) | ||
* plugins/LayerSource.js | ||
*/ | ||
Ext.ns("gxp.plugins"); | ||
|
||
/** api: constructor | ||
* .. class:: MapBoxSource(config) | ||
* | ||
* Plugin for using MapBox layers with :class:`gxp.Viewer` instances. | ||
* Freely available for commercial and non-commercial use according to the | ||
* MapBox terms of service: http://mapbox.com/tos | ||
* | ||
* Available layer names: | ||
* * blue-marble-topo-bathy-jan | ||
* * blue-marble-topo-bathy-jul | ||
* * blue-marble-topo-jan | ||
* * blue-marble-topo-jul | ||
* * control-room | ||
* * geography-class | ||
* * natural-earth-hypso | ||
* * natural-earth-hypso-bathy | ||
* * natural-earth-1 | ||
* * natural-earth-2 | ||
* * world-dark | ||
* * world-light | ||
* * world-print | ||
* | ||
*/ | ||
/** api: example | ||
* The configuration in the ``sources`` property of the :class:`gxp.Viewer` is | ||
* straightforward: | ||
* | ||
* .. code-block:: javascript | ||
* | ||
* mapbox: { | ||
* ptype: "gxp_mapboxsource" | ||
* } | ||
* | ||
* A typical configuration for a layer from this source (in the ``layers`` | ||
* array of the viewer's ``map`` config option would look like this: | ||
* | ||
* .. code-block:: javascript | ||
* | ||
* { | ||
* source: "mapbox", | ||
* name: "blue-marble-topo-bathy-jan" | ||
* } | ||
* | ||
*/ | ||
gxp.plugins.TileStreamSource = Ext.extend(gxp.plugins.LayerSource, { | ||
|
||
/** api: ptype = gxp_mapboxsource */ | ||
ptype: "gxp_tilestreamsource", | ||
|
||
/** api: property[store] | ||
* ``GeoExt.data.LayerStore``. Will contain records with name field values | ||
* matching MapBox layer names. | ||
*/ | ||
|
||
/** api: config[title] | ||
* ``String`` | ||
* A descriptive title for this layer source (i18n). | ||
*/ | ||
title: "GEM Tile Layers", | ||
|
||
/** i18n **/ | ||
hazardMapPointsWorldTitle: "Hazard Map PGA_0.1", | ||
whiteBaseTitle: "GEM Base Map", | ||
gdalCustomUrbanTitle: "GDAL Urban Population", | ||
gdalCustomRuralTitle: "GDAL Rural Population", | ||
|
||
/** api: method[createStore] | ||
* | ||
* Creates a store of layer records. Fires "ready" when store is loaded. | ||
*/ | ||
createStore: function() { | ||
|
||
var options = { | ||
sphericalMercator: true, | ||
wrapDateLine: true, | ||
numZoomLevels: 7 | ||
}; | ||
|
||
var configs = [ | ||
{name: "hazard-map-points-world", numZoomLevels: 7}, | ||
{name: "white-base", numZoomLevels: 7}, | ||
{name: "gdal-custom-urban", numZoomLevels: 7}, | ||
{name: "gdal-custom-rural", numZoomLevels: 7} | ||
]; | ||
|
||
var len = configs.length; | ||
var layers = new Array(len); | ||
var config; | ||
for (var i=0; i<len; ++i) { | ||
config = configs[i]; | ||
layers[i] = new OpenLayers.Layer.XYZ( | ||
this[OpenLayers.String.camelize(config.name) + "Title"], | ||
[ | ||
//connect to the hope tilestream server | ||
"http://193.206.66.82:8000/v2/" + config.name + "/${z}/${x}/${y}.png" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment saying which server this IP number refers to? |
||
], | ||
OpenLayers.Util.applyDefaults({ | ||
layername: config.name, | ||
//"abstract": '<div class="thumb-mapbox thumb-mapbox-'+config.name+'"></div>', | ||
numZoomLevels: config.numZoomLevels | ||
}, options) | ||
); | ||
} | ||
|
||
this.store = new GeoExt.data.LayerStore({ | ||
layers: layers, | ||
fields: [ | ||
{name: "source", type: "string"}, | ||
{name: "name", type: "string", mapping: "layername"}, | ||
//{name: "abstract", type: "string"}, | ||
{name: "group", type: "string"}, | ||
{name: "fixed", type: "boolean"}, | ||
{name: "selected", type: "boolean"} | ||
] | ||
}); | ||
this.fireEvent("ready", this); | ||
|
||
}, | ||
|
||
/** api: method[createLayerRecord] | ||
* :arg config: ``Object`` The application config for this layer. | ||
* :returns: ``GeoExt.data.LayerRecord`` | ||
* | ||
* Create a layer record given the config. | ||
*/ | ||
createLayerRecord: function(config) { | ||
var record; | ||
var index = this.store.findExact("name", config.name); | ||
if (index > -1) { | ||
|
||
record = this.store.getAt(index).copy(Ext.data.Record.id({})); | ||
var layer = record.getLayer().clone(); | ||
|
||
// set layer title from config | ||
if (config.title) { | ||
/** | ||
* Because the layer title data is duplicated, we have | ||
* to set it in both places. After records have been | ||
* added to the store, the store handles this | ||
* synchronization. | ||
*/ | ||
layer.setName(config.title); | ||
record.set("title", config.title); | ||
} | ||
|
||
// set visibility from config | ||
if ("visibility" in config) { | ||
layer.visibility = config.visibility; | ||
} | ||
|
||
record.set("selected", config.selected || false); | ||
record.set("source", config.source); | ||
record.set("name", config.name); | ||
if ("group" in config) { | ||
record.set("group", config.group); | ||
} | ||
|
||
record.data.layer = layer; | ||
record.commit(); | ||
} | ||
return record; | ||
} | ||
|
||
}); | ||
|
||
Ext.preg(gxp.plugins.TileStreamSource.prototype.ptype, gxp.plugins.TileStreamSource); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment where you describe that you hacked the original TileStreamSource plugin to make it work with server x, tile y, etc. etc.?