Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Tilestream plugin #30

Merged
merged 16 commits into from Apr 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion oq-ui-api/bin/oq-platform-install.sh
Expand Up @@ -18,7 +18,7 @@
# version managements - use "master" or tagname to move to other versions

export GEM_OQ_PLATF_GIT_REPO=git://github.com/gem/oq-platform.git
export GEM_OQ_PLATF_GIT_VERS="v1.12.12"
export GEM_OQ_PLATF_GIT_VERS="master"

export GEM_OQ_PLATF_SUBMODS="oq-ui-client/app/static/externals/geoext
oq-ui-client/app/static/externals/gxp
Expand Down Expand Up @@ -400,6 +400,14 @@ psql -f $GEM_POSTGIS_PATH/spatial_ref_sys.sql template_postgis
sed -i "s/DATABASE_NAME[ ]*=[ ]*'\([^']*\)'/DATABASE_NAME = '$GEM_DB_NAME'/g" "$GEM_GN_LOCSET"
sed -i "s@\(<url>jdbc:postgresql:\)[^<]*@\1$GEM_DB_NAME@g" "$GEM_NW_SETTINGS"

#update the local_settings.py with tilestream plugin sorce
grep -q " 'source': {'ptype': 'gxp_tilestreamsource'}, " "$GEM_GN_LOCSET"
if [ $? -eq 0 ]; then
echo "gxp_tilestreamsource is already installed"
else
sed -i "s@MAP_BASELAYERS *= *\[{@MAP_BASELAYERS = [{\n 'source': {'ptype': 'gxp_tilestreamsource'}, \n }, { \n@g" "$GEM_GN_LOCSET"
fi

service apache2 start
tc_log_cur="$(cat /var/log/geonode/tomcat.log | wc -l)"
service tomcat6 start
Expand Down
1 change: 1 addition & 0 deletions oq-ui-api/etc/geonode/static/geonode/script/gxp.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions oq-ui-client2/src/app/isc_viewer.js
Expand Up @@ -18,6 +18,7 @@
* @require plugins/GoogleSource.js
* @require plugins/GoogleGeocoder.js
* @require plugins/Legend.js
* @require plugins/TileStreamSource.js
*/

var app;
Expand Down Expand Up @@ -112,6 +113,9 @@ Ext.onReady(function() {
url: "/geoserver/wms",
version: "1.1.1"
},
mapbox: {
ptype: "gxp_tilestreamsource"
},
osm: {
ptype: "gxp_osmsource"
},
Expand Down
197 changes: 197 additions & 0 deletions oq-ui-client2/src/gxp/script/plugins/TileStreamSource.js
@@ -0,0 +1,197 @@
/**
Copy link
Contributor

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.?


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"
Copy link
Contributor

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 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);