diff --git a/map180/README.md b/map180/README.md index 088b7845..de5f3b19 100644 --- a/map180/README.md +++ b/map180/README.md @@ -22,7 +22,7 @@ Postgres 9.* with Postgis 2.* ## Using the Assembled Data * Create the tables (and associated indexed) `public.map180_layers` and `public.map180_labels`. See `etc/nz_map180_layer.ddl` -* Load the data e.g., for the fits db: `psql -h 127.0.0.1 fits postgres -f data/new_zealand_map_layers.ddl` +* Load the data e.g.: `psql -h 127.0.0.1 example_db postgres -f data/new_zealand_map_layers.ddl` If necessary change the schema, table, and user access as required. They can be specificed in map180.Init() @@ -37,7 +37,7 @@ was made from shape files that where loaded into the DB and then cut and transfo The files `etc/load-nz-shp.sh` and `etc/nz_map180_layer.ddl` document the process of creating `public.map180_layers`. This was then dumped using: ``` -pg_dump -h 127.0.0.1 --table=public.map180_layers --table=public.map180_labels --data-only -U postgres fits -f data/new_zealand_map_layers.ddl +pg_dump -h 127.0.0.1 --table=public.map180_layers --table=public.map180_labels --data-only -U postgres example_db -f data/new_zealand_map_layers.ddl ``` The assembled New Zealand data set uses data sourced from: diff --git a/map180/etc/load-nz-shp.sh b/map180/etc/load-nz-shp.sh index 3754d9b0..534296de 100644 --- a/map180/etc/load-nz-shp.sh +++ b/map180/etc/load-nz-shp.sh @@ -1,22 +1,22 @@ #!/bin/sh -# adjust the database being connected to as you require. This uses 'fits'. +# adjust the database being connected to as you require. This uses 'example_db'. -shp2pgsql -d -s 4326 -I /work/shp/ne_50m_land.shp public.ne50land | psql -h localhost fits postgres -shp2pgsql -d -W "LATIN1" -s 4326 -I /work/shp/ne_50m_lakes.shp public.ne50lakes | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/ne_10m_minor_islands.shp public.ne10minorislands | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/ne_10m_land.shp public.ne10land | psql -h localhost fits postgres -shp2pgsql -d -W "LATIN1" -s 4326 -I /work/shp/ne_10m_lakes.shp public.ne10lakes | psql -h localhost fits postgres +shp2pgsql -d -s 4326 -I /work/shp/ne_50m_land.shp public.ne50land | psql -h localhost example_db postgres +shp2pgsql -d -W "LATIN1" -s 4326 -I /work/shp/ne_50m_lakes.shp public.ne50lakes | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/ne_10m_minor_islands.shp public.ne10minorislands | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/ne_10m_land.shp public.ne10land | psql -h localhost example_db postgres +shp2pgsql -d -W "LATIN1" -s 4326 -I /work/shp/ne_10m_lakes.shp public.ne10lakes | psql -h localhost example_db postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-chatham-is-island-polygons-topo-1250k.shp public.nztopo_1250k_chathams_land | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-chatham-is-lagoon-polygons-topo-1250k.shp public.nztopo_1250k_chathams_lagoon | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-coastlines-and-islands-polygons-topo-1500k.shp public.nztopo_1500k_land | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-coastlines-and-islands-polygons-topo-150k.shp public.nztopo_150k_land | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-lake-polygons-topo-1500k.shp public.nztopo_1500k_lakes | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-mainland-lake-polygons-topo-150k.shp public.nztopo_150k_lakes| psql -h localhost fits postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-chatham-is-island-polygons-topo-1250k.shp public.nztopo_1250k_chathams_land | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-chatham-is-lagoon-polygons-topo-1250k.shp public.nztopo_1250k_chathams_lagoon | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-coastlines-and-islands-polygons-topo-1500k.shp public.nztopo_1500k_land | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-coastlines-and-islands-polygons-topo-150k.shp public.nztopo_150k_land | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-lake-polygons-topo-1500k.shp public.nztopo_1500k_lakes | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-mainland-lake-polygons-topo-150k.shp public.nztopo_150k_lakes| psql -h localhost example_db postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-kermadec-is-lake-polygons-topo-125k/nz-kermadec-is-lake-polygons-topo-125k.shp public.nztopo_125k_kermadec_lakes | psql -h localhost fits postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-kermadec-is-lake-polygons-topo-125k/nz-kermadec-is-lake-polygons-topo-125k.shp public.nztopo_125k_kermadec_lakes | psql -h localhost example_db postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-geographic-names-topo-1500k.shp public.nztopo_1500k_names | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-chatham-is-geographic-names-topo-1250k.shp public.nztopo_1250k_chatham_names | psql -h localhost fits postgres -shp2pgsql -d -s 4326 -I /work/shp/nz-kermadec-is-geographic-names-topo-125k/nz-kermadec-is-geographic-names-topo-125k.shp public.nztopo_125k_kermadec_names | psql -h localhost fits postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-geographic-names-topo-1500k.shp public.nztopo_1500k_names | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-chatham-is-geographic-names-topo-1250k.shp public.nztopo_1250k_chatham_names | psql -h localhost example_db postgres +shp2pgsql -d -s 4326 -I /work/shp/nz-kermadec-is-geographic-names-topo-125k/nz-kermadec-is-geographic-names-topo-125k.shp public.nztopo_125k_kermadec_names | psql -h localhost example_db postgres diff --git a/weft/assets_test.go b/weft/assets_test.go index 333513cd..7d33ccce 100644 --- a/weft/assets_test.go +++ b/weft/assets_test.go @@ -26,15 +26,15 @@ func TestLoadAssets(t *testing.T) { }, { "Load JS file", - "testdata/gnss-map-plot.js", + "testdata/test.js", &asset{ - path: "/gnss-map-plot.js", - hashedPath: "/e83a0b0f-gnss-map-plot.js", + path: "/test.js", + hashedPath: "/7ae97332-test.js", mime: "text/javascript", fileType: "js", - sri: "sha384-haxRijtRHhpn6nbt+JNpioqOj0AwB+THIaVdUZ34R9sQrQL2vmf/pn6GPnQq+AI1", + sri: "sha384-QpJfAj2w6B/9M/RPFCW5SdxSs8wf4DRuer8K06bMu8cqj0Cu91WZYh4spHDPmKO/", }, - 8513, + 56, }, { "Load MJS file", @@ -107,8 +107,8 @@ func TestCreateSubResourceTag(t *testing.T) { }, {"abcdefgh", "async", - "testdata/gnss-map-plot.js", - ``, + "testdata/test.js", + ``, }, {"ijklmnop", "defer", diff --git a/weft/testdata/gnss-map-plot.js b/weft/testdata/gnss-map-plot.js deleted file mode 100644 index 9b27d673..00000000 --- a/weft/testdata/gnss-map-plot.js +++ /dev/null @@ -1,234 +0,0 @@ -/********************************************************* - * GeoNet GNSS data plot client application ****** - * -- leaflet map showing sites - * -- static plot for selected site and data type - * - * - * baishan 30/7/2017 - **********************************************************/ - -var $ = jQuery.noConflict(); - -/****** all the chart functionalities defined here ******/ -var gnssPlotClient = { - //### 1. constants and vars - NZ_CENTRE: new L.LatLng(-40.5, 174.5), - //sites data by param - SITES_DATA_URL: "/p/fits/site?typeID=e&methodID=gamit", - allSitesData: null, - lftMap: null, - - //### 2. functions - /*** - * init parameters, called from page - * ***/ - initParams: function () { - this.initBaseMap(); - this.initControlFunctions(); - this.showSites(); - this.initEvents(); - }, - - /*** - * init leaflet basemap - * ***/ - initBaseMap: function () { - var osmUrl = '//{s}.geonet.org.nz/osm/v2/{z}/{x}/{y}.png', - osmLayer = new L.TileLayer(osmUrl, { - minZoom: 1, - maxZoom: 18, - errorTileUrl: '//static.geonet.org.nz/osm/images/logo_geonet.png', - subdomains: ['static1', 'static2', 'static3', 'static4', 'static5'] - }); - - this.lftMap = L.map('gnss-sites-map', { - attributionControl: false, - zoom: 18, - layers: [osmLayer] - }); - - //L.control.layers(baseLayers).addTo(this.lftMap); - this.lftMap.setView(this.NZ_CENTRE, 5); - }, - - /** - * get the copyrights popover working - */ - initControlFunctions: function () { - jQuery("a[rel=popover]") - .popover({ - html: true, - trigger: 'hover', - delay: { - hide: 500, - show: 80 - }, - placement: function (tip, element) { - var offset = jQuery(element).offset(); - var height = jQuery(document).outerHeight(); - var width = jQuery(document).outerWidth(); - var vert = 0.5 * height - offset.top; - var vertPlacement = vert > 0 ? 'bottom' : 'top'; - var horiz = 0.5 * width - offset.left; - var horizPlacement = horiz > 0 ? 'right' : 'left'; - var placement = Math.abs(horiz) > Math.abs(vert) ? horizPlacement : vertPlacement; - return placement; - } - }) - .click(function (e) { - e.preventDefault(); - }); - - }, - - /*** - * show sites on map - * ***/ - showSitesDataOnMap: function (sitesJson) { - var sitesLayer = new L.GeoJSON1(sitesJson, { - - pointToLayer: function (feature, latlng) { - var iconSize = 12; - var iconSizeLarge = 18; - var svgURL = gnssPlotClient.getSiteIconSVG('#3366AA'); - var svgURLSelected = gnssPlotClient.getSiteIconSVG('#f4f450'); - gnssPlotClient.sVGIcon = L.icon({ - iconUrl: svgURL, - iconSize: [iconSize, iconSize], - shadowSize: [0, 0], - iconAnchor: [0.5 * iconSize, 0.5 * iconSize], - popupAnchor: [0, 0] - }); - gnssPlotClient.sVGIconSelected = L.icon({ - iconUrl: svgURLSelected, - iconSize: [iconSizeLarge, iconSizeLarge], - shadowSize: [0, 0], - iconAnchor: [0.5 * iconSizeLarge, 0.5 * iconSizeLarge], - popupAnchor: [0, 0] - }); - - var marker = L.marker(latlng, { - icon: gnssPlotClient.sVGIcon, - riseOnHover: true, - zIndexOffset: 150 - }); - - marker.on('click', function () { - if (gnssPlotClient.selectedMarker) {//if any marker is already selected, set to normal - gnssPlotClient.selectedMarker.setIcon(gnssPlotClient.sVGIcon); - gnssPlotClient.selectedMarker.setZIndexOffset(150); - } - gnssPlotClient.selectedMarker = this; - gnssPlotClient.showSitePlots(feature.properties.siteID, feature.properties.networkID, feature.properties.name); - this.setIcon(gnssPlotClient.sVGIconSelected); - this.setZIndexOffset(160); - }); - - return marker; - } - }); - this.lftMap.addLayer(sitesLayer); - sitesLayer.checkFeatureLocation(); - }, - - getSiteIconSVG: function (iconColor, borderColor) { - var iconSize = 6, - borderWidth = 1; - if (!iconColor) { - iconColor = '#3366AA'; - } - if (!borderColor) { - borderColor = '#111c1c'; - } - // here's the trick, base64 encode the URL - var svgIcon = "" - + ""; - - return "data:image/svg+xml;base64," + btoa(svgIcon); - - }, - - showSitePlots: function (siteId, networkId, siteName) { - if (siteId && siteName) { - this.siteId = siteId; - this.networkId = networkId; - this.siteName = siteName; - } - var plottype = jQuery("input[name='plotRadios']:checked").val(); - var plotTypes; - var title; - if (plottype === 'displacement') { - plotTypes = ['e', 'n', 'u']; - } else { - plotTypes = ['mp1', 'mp2']; - } - if (this.siteId) { - $('#gnss-chart').empty(); - this.allImages = plotTypes.length; - this.imagesLoaded = 0; - for (var i = 0; i < plotTypes.length; i++) { - var imgurl = '/data/gnss/plot/' + this.siteId + '/' + plotTypes[i]; - if (this.networkId) { - imgurl += '/' + this.networkId; - } - //console.log("imgurl " + imgurl); - $('', { - 'src': imgurl, - 'width': "100%" - }).on('load', function () { - gnssPlotClient.onImageLoad(); - }).appendTo('#gnss-chart'); - - $('
').appendTo('#gnss-chart'); - } - //change layout - jQuery("#gnss-map-container").removeClass("col-lg-10").addClass("col-lg-5"); - this.lftMap.invalidateSize(); - //show plots - jQuery("#gnss-plot-container").css("display", "block"); - title = "GNSS Time Series Plot - " + this.siteName; - jQuery("#gnss-plot-header").html(title); - } - - }, - - onImageLoad: function () { - this.imagesLoaded++; - if (this.imagesLoaded >= this.allImages) {//when all images have been loaded - //scroll to plot on small screen size - if (jQuery(window).width() < 992) {// - var element = jQuery("#gnss-plot-container"); - jQuery('html, body').scrollTop(element.offset().top); - } - } - }, - - initEvents: function () { - jQuery("input[name='plotRadios']").on('change', function () { - gnssPlotClient.showSitePlots(); - }); - - }, - - /*** - * query sites from http - * ***/ - showSites: function () { - var sitesData = this.allSitesData; - //console.log("sitesData " + sitesData); - if (sitesData) { - this.showSitesDataOnMap(sitesData); - } else { - var url = this.SITES_DATA_URL; - //console.log("show sites " + " url " + url); - jQuery.getJSON(url, function (data) { - //console.log(JSON.stringify(data)); - gnssPlotClient.allSitesData = data; - gnssPlotClient.showSitesDataOnMap(data); - }); - } - } -}; - diff --git a/weft/testdata/test.js b/weft/testdata/test.js new file mode 100644 index 00000000..343fdc04 --- /dev/null +++ b/weft/testdata/test.js @@ -0,0 +1,3 @@ +function helloWorld() { + console.log("hello world") +} \ No newline at end of file