aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Map')
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm71
-rw-r--r--perllib/FixMyStreet/Map/OSM/CycleMap.pm71
-rw-r--r--perllib/FixMyStreet/Map/OSM/StreetView.pm70
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm83
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm81
5 files changed, 376 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
new file mode 100644
index 000000000..ccbb3ca53
--- /dev/null
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::OSM
+# OSM maps on FixMyStreet.
+#
+# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map;
+
+use strict;
+use mySociety::Web qw(ent);
+
+sub header_js {
+ return '
+<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
+<script type="text/javascript" src="/js/map-OpenStreetMap.js"></script>
+<script type="text/javascript" src="/js/OpenLayers.Projection.OrdnanceSurvey.js"></script>
+';
+}
+
+# display_map Q PARAMS
+# PARAMS include:
+# EASTING, NORTHING for the centre point of the map
+# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
+# 0 if not clickable
+# PINS is array of pins to show, location and colour
+# PRE/POST are HTML to show above/below map
+sub display_map {
+ my ($q, %params) = @_;
+ $params{pre} ||= '';
+ $params{post} ||= '';
+
+ foreach my $pin (@{$params{pins}}) {
+ }
+
+ my $out = FixMyStreet::Map::header($q, $params{type});
+ my $copyright = _('Map &copy; <a href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>');
+ $out .= <<EOF;
+<script type="text/javascript">
+var fixmystreet = {
+ 'easting': $params{easting},
+ 'northing': $params{northing},
+ 'map_type': OpenLayers.Layer.OSM.Mapnik
+}
+</script>
+<div id="map_box">
+ $params{pre}
+ <div id="map"></div>
+ <p id="copyright">$copyright</p>
+ $params{post}
+</div>
+<div id="side">
+EOF
+ return $out;
+}
+
+sub display_map_end {
+ my ($type) = @_;
+ my $out = '</div>';
+ $out .= '</form>' if ($type);
+ return $out;
+}
+
+sub display_pin {
+}
+
+sub map_pins {
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/OSM/CycleMap.pm b/perllib/FixMyStreet/Map/OSM/CycleMap.pm
new file mode 100644
index 000000000..01c51acf4
--- /dev/null
+++ b/perllib/FixMyStreet/Map/OSM/CycleMap.pm
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::OSM::CycleMap
+# OSM CycleMap maps on FixMyStreet.
+#
+# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map;
+
+use strict;
+use mySociety::Web qw(ent);
+
+sub header_js {
+ return '
+<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
+<script type="text/javascript" src="/js/map-OpenStreetMap.js"></script>
+<script type="text/javascript" src="/js/OpenLayers.Projection.OrdnanceSurvey.js"></script>
+';
+}
+
+# display_map Q PARAMS
+# PARAMS include:
+# EASTING, NORTHING for the centre point of the map
+# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
+# 0 if not clickable
+# PINS is array of pins to show, location and colour
+# PRE/POST are HTML to show above/below map
+sub display_map {
+ my ($q, %params) = @_;
+ $params{pre} ||= '';
+ $params{post} ||= '';
+
+ foreach my $pin (@{$params{pins}}) {
+ }
+
+ my $out = FixMyStreet::Map::header($q, $params{type});
+ my $copyright = _('Map &copy; <a href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>');
+ $out .= <<EOF;
+<script type="text/javascript">
+var fixmystreet = {
+ 'easting': $params{easting},
+ 'northing': $params{northing},
+ 'map_type': OpenLayers.Layer.OSM.CycleMap
+}
+</script>
+<div id="map_box">
+ $params{pre}
+ <div id="map"></div>
+ <p id="copyright">$copyright</p>
+ $params{post}
+</div>
+<div id="side">
+EOF
+ return $out;
+}
+
+sub display_map_end {
+ my ($type) = @_;
+ my $out = '</div>';
+ $out .= '</form>' if ($type);
+ return $out;
+}
+
+sub display_pin {
+}
+
+sub map_pins {
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/OSM/StreetView.pm b/perllib/FixMyStreet/Map/OSM/StreetView.pm
new file mode 100644
index 000000000..08f677d25
--- /dev/null
+++ b/perllib/FixMyStreet/Map/OSM/StreetView.pm
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::OSM::StreetView
+# OSM StreetView maps on FixMyStreet.
+#
+# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map;
+
+use strict;
+use mySociety::Web qw(ent);
+
+sub header_js {
+ return '
+<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
+<script type="text/javascript" src="/js/map-streetview.js"></script>
+<script type="text/javascript" src="/js/OpenLayers.Projection.OrdnanceSurvey.js"></script>
+';
+}
+
+# display_map Q PARAMS
+# PARAMS include:
+# EASTING, NORTHING for the centre point of the map
+# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
+# 0 if not clickable
+# PINS is array of pins to show, location and colour
+# PRE/POST are HTML to show above/below map
+sub display_map {
+ my ($q, %params) = @_;
+ $params{pre} ||= '';
+ $params{post} ||= '';
+
+ foreach my $pin (@{$params{pins}}) {
+ }
+
+ my $out = FixMyStreet::Map::header($q, $params{type});
+ my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
+ $out .= <<EOF;
+<script type="text/javascript">
+var fixmystreet = {
+ 'easting': $params{easting},
+ 'northing': $params{northing}
+}
+</script>
+<div id="map_box">
+ $params{pre}
+ <div id="map"></div>
+ <p id="copyright">$copyright</p>
+ $params{post}
+</div>
+<div id="side">
+EOF
+ return $out;
+}
+
+sub display_map_end {
+ my ($type) = @_;
+ my $out = '</div>';
+ $out .= '</form>' if ($type);
+ return $out;
+}
+
+sub display_pin {
+}
+
+sub map_pins {
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
new file mode 100644
index 000000000..b1fe0126d
--- /dev/null
+++ b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::Tilma::1_10k_OL
+# Using tilma.mysociety.org with OpenLayers
+#
+# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map;
+
+use strict;
+
+use constant TILE_WIDTH => 254;
+use constant TIF_SIZE_M => 5000;
+use constant TIF_SIZE_PX => 7874;
+use constant SCALE_FACTOR => TIF_SIZE_M / (TIF_SIZE_PX / TILE_WIDTH);
+use constant TILE_TYPE => '10k-full';
+
+sub header_js {
+ return '
+<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
+<script type="text/javascript" src="/js/map-tilma-ol.js"></script>
+';
+}
+
+# display_map Q PARAMS
+# PARAMS include:
+# EASTING, NORTHING for the centre point of the map
+# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
+# 0 if not clickable
+# PINS is array of pins to show, location and colour
+# PRE/POST are HTML to show above/below map
+sub display_map {
+ my ($q, %params) = @_;
+ $params{pre} ||= '';
+ $params{post} ||= '';
+
+ foreach my $pin (@{$params{pins}}) {
+ }
+
+ my $out = FixMyStreet::Map::header($q, $params{type});
+ my $tile_width = TILE_WIDTH;
+ my $tile_type = TILE_TYPE;
+ my $sf = SCALE_FACTOR / TILE_WIDTH;
+ my $copyright = _('&copy; Crown copyright. All rights reserved. Ministry of Justice 100037819&nbsp;2008.');
+ $out .= <<EOF;
+<script type="text/javascript">
+var fixmystreet = {
+ 'tilewidth': $tile_width,
+ 'tileheight': $tile_width,
+ 'easting': $params{easting},
+ 'northing': $params{northing},
+ 'tile_type': '$tile_type',
+ 'maxResolution': $sf
+};
+</script>
+<div id="map_box">
+ $params{pre}
+ <div id="map">
+ <div id="watermark"></div>
+ </div>
+ <p id="copyright">$copyright</p>
+$params{post}
+</div>
+<div id="side">
+EOF
+ return $out;
+}
+
+sub display_map_end {
+ my ($type) = @_;
+ my $out = '</div>';
+ $out .= '</form>' if ($type);
+ return $out;
+}
+
+sub display_pin {
+}
+
+sub map_pins {
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
new file mode 100644
index 000000000..7ef372351
--- /dev/null
+++ b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::TilmaXY
+# Using tilma.mysociety.org but accessing images directly.
+#
+# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map;
+
+use strict;
+
+use constant TILE_WIDTH => 250;
+use constant TIF_SIZE_M => 5000;
+use constant TIF_SIZE_PX => 5000;
+use constant SCALE_FACTOR => TIF_SIZE_M / (TIF_SIZE_PX / TILE_WIDTH);
+use constant TILE_TYPE => 'streetview';
+
+sub header_js {
+ return '
+<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
+<script type="text/javascript" src="/js/map-tilma-ol.js"></script>
+';
+}
+
+# display_map Q PARAMS
+# PARAMS include:
+# EASTING, NORTHING for the centre point of the map
+# TYPE is 1 if the map is clickable, 2 if clickable and has a form upload,
+# 0 if not clickable
+# PINS is array of pins to show, location and colour
+# PRE/POST are HTML to show above/below map
+sub display_map {
+ my ($q, %params) = @_;
+ $params{pre} ||= '';
+ $params{post} ||= '';
+
+ foreach my $pin (@{$params{pins}}) {
+ }
+
+ my $out = FixMyStreet::Map::header($q, $params{type});
+ my $tile_width = TILE_WIDTH;
+ my $tile_type = TILE_TYPE;
+ my $sf = SCALE_FACTOR / TILE_WIDTH;
+ my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
+ $out .= <<EOF;
+<script type="text/javascript">
+var fixmystreet = {
+ 'tilewidth': $tile_width,
+ 'tileheight': $tile_width,
+ 'easting': $params{easting},
+ 'northing': $params{northing},
+ 'tile_type': '$tile_type',
+ 'maxResolution': $sf
+};
+</script>
+<div id="map_box">
+ $params{pre}
+ <div id="map"></div>
+ <p id="copyright">$copyright</p>
+ $params{post}
+</div>
+<div id="side">
+EOF
+ return $out;
+}
+
+sub display_map_end {
+ my ($type) = @_;
+ my $out = '</div>';
+ $out .= '</form>' if ($type);
+ return $out;
+}
+
+sub display_pin {
+}
+
+sub map_pins {
+}
+
+1;