Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged with master

  • Loading branch information...
commit c851cfbf0d6ab506043fce72410c5d7a41f26941 2 parents 97793cf + feb28e6
@jrasky jrasky authored
View
20,709 geocamTiePoint/static/external/js/ember-1.0.pre.js
0 additions, 20,709 deletions not shown
View
18 geocamTiePoint/static/external/js/ember-1.0.pre.min.js
0 additions, 18 deletions not shown
View
4,176 geocamTiePoint/static/external/js/ember-data.js
0 additions, 4,176 deletions not shown
View
23 geocamTiePoint/static/geocamTiePoint/css/backbone.css
@@ -118,3 +118,26 @@ input#locationSearch {
.error{
color: red;
}
+
+.navbar .nav li a {
+ padding-bottom: 0px;
+}
+
+p.pull-right.navbar-text {
+ padding-top: 15px;
+}
+
+a.btn-primary {
+ color: #ffffff;
+}
+
+.import-requirements {
+ padding-left: 15px;
+ font-size: 0.9em;
+ color: #888888;
+ padding-bottom: 10px;
+}
+
+#newOverlayFile {
+ padding-bottom: 10px;
+}
View
10 geocamTiePoint/static/geocamTiePoint/js/backbone/models.js
@@ -147,11 +147,15 @@ $(function($) {
var model = this;
model.trigger('before_warp');
saveOptions = {
- error: function(){
+ error: function(model, response){
+ if ( response.readyState < 4 ) {
+ model.trigger('warp_server_unreachable');
+ } else {
+ model.trigger('warp_server_error');
+ }
if (options.error) options.error();
- model.trigger('warp_error');
},
- success: function() {
+ success: function(model, response) {
if (options.success) options.success();
model.trigger('warp_success');
},
View
155 geocamTiePoint/static/geocamTiePoint/js/backbone/views.js
@@ -66,8 +66,8 @@ $(function($) {
app.views.HomeView = app.views.View.extend({
template: '<div style="max-width: 800px">'+
'<p>MapFasten helps you quickly align an image or PDF with a map, '+
- 'creating a shareable map overlay that you can display in the Google Maps'+
- 'API or in KML and combine with other layers.</p>'+
+ 'creating a shareable map layer that you can display in maps ' +
+ 'based on the Google Maps API and combine with other layers.</p>'+
'<p><a class="welcomeEntry" href="#overlays/">Let\'s get started &gt;&gt;</a></p>'+
'</div>',
});
@@ -252,60 +252,6 @@ $(function($) {
}, this));
},
- initZoomHotkey: function() {
- var zoomFactor = 4;
- var originalZoom = null;
- var view = this;
- var zoomed = false;
- var mousePosition = null;
- var mouseDown = null;
-
- function enhance() {
- console.log('ENHANCE!');
- originalZoom = view.gmap.getZoom();
- var targetZoom = Math.max(originalZoom + zoomFactor,
- view.model.maxZoom());
- //var targetZoom = view.model.maxZoom();
- view.gmap.setZoom(targetZoom);
- view.gmap.panTo(mousePosition);
- }
-
- function unenhance() {
- view.gmap.setZoom(originalZoom);
- }
-
- google.maps.event.addListener(view.gmap, 'mousemove', function(e) {
- mousePosition = e.latLng;
- });
-
- google.maps.event.addListener(view.gmap, 'mouseout', function(e) {
- mousePosition = null;
- });
- google.maps.event.addListener(view.gmap, 'mousedown', function(e) {
- mouseDown = true;
- });
- google.maps.event.addListener(view.gmap, 'mouseup', function(e) {
- mouseDown = false;
- });
-
- $(window).keydown(function(e) {
- //console.log(e.which);
- if (mousePosition && ! mouseDown &&
- e.which === 90 && // z key
- ! zoomed) {
- zoomed = true;
- enhance();
- }
- });
-
- $(window).keyup(function(e) {
- //console.log(e.which);
- if (zoomed && e.which === 90) { // z key
- unenhance();
- zoomed = false;
- }
- });
- }
}); // end OverlayGoogleMapsView base class
app.views.ImageQtreeView = app.views.OverlayGoogleMapsView.extend({
@@ -323,6 +269,7 @@ $(function($) {
streetViewControl: false,
backgroundColor: 'rgb(192, 192, 192)',
mapTypeControl: false,
+ draggableCursor: 'crosshair'
});
var gmap = app.gmap;
@@ -343,7 +290,6 @@ $(function($) {
this.gmap = gmap;
this.drawMarkers();
this.trigger('gmap_loaded');
- //this.initZoomHotkey();
},
drawMarkers: function() {
@@ -387,7 +333,8 @@ $(function($) {
var mapOptions = {
zoom: 6,
- mapTypeId: google.maps.MapTypeId.ROADMAP
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
+ draggableCursor: 'crosshair'
};
var gmap = new google.maps.Map(this.$('#map_canvas')[0],
@@ -418,7 +365,6 @@ $(function($) {
this.drawMarkers();
}
this.trigger('gmap_loaded');
- //this.initZoomHotkey();
/* Events and init for the qtree overlay */
this.model.on('change:points', function(){
@@ -493,16 +439,18 @@ $(function($) {
this.$('#locationSearch').focus();
flicker(
function () {
- this.$('#locationSearch').css('background-color', '#ffc');
+ this.$('#locationSearch').css('background-color', '#aaf');
+ //this.$('#locationSearch').css('border', 'solid 4px blue').css('padding', '-2');
},
function () {
this.$('#locationSearch').css('background-color', '#fff');
+ // this.$('#locationSearch').css('border', 'none');
},
- 1000, 3);
+ 500, 8);
}],
['Click matching landmarks on both sides to add tiepoints and align your overlay.',
lorem],
- ['Use "Export" to see options for viewing your overlay in maps outside this site.',
+ ['Use "Share" to see options for viewing your overlay in maps outside this site.',
lorem,
function () {
this.$('#export').focus();
@@ -524,6 +472,7 @@ $(function($) {
'<input type="text" id="locationSearch" placeholder="Location"></input>' +
'</span>' +
'<span class="alert instructions-prompt">'+
+ '<strong style="float:left; margin-right:1em;">Tips:</strong>'+
'<div class="btn-group floatleft" style="margin-right: 10px;">'+
'<a id="promptPrevStep" class="btn btn-mini">&lt;&lt;</a>'+
'<a id="promptNextStep" class="btn btn-mini">&gt;&gt;</a>'+
@@ -548,9 +497,9 @@ $(function($) {
'</div>' +
'<button class="btn"><label for="show_preview"><input id="show_preview" type="checkbox" checked="true"/>Show Preview</label></button>' +
'<div id="save-export" class="btn-group">'+
- '<button class="btn" id="export">Export</button>'+
+ '<button class="btn" id="export">Share</button>'+
'<button class="btn" id="save">Save</button>'+
- '<span id="saveStatus" data-saving-text="Saving..." data-saved-text="Saved." data-save-error="SAVE ERROR!"></span>'+
+ '<span id="saveStatus" data-saving-text="Saving..." data-changed-text="Changed since last save" data-saved-text="Saved." data-server-error="Server Error" data-server-unreachable="Server unreachable"></span>'+
'</div>'+
'</div>' +
'<div id="split_container">' +
@@ -686,15 +635,35 @@ $(function($) {
view.zoomFit();
});
$(document).keyup(function(e) {
- //console.log('key detect: ' + e.which);
- if (e.which === 122 || e.which === 90) { // match z or Z
- zoomed = !zoomed;
- if (zoomed) {
- view.zoomMaximum();
- } else {
- view.zoomFit();
- }
+ console.log('key detect: ' + e.which);
+ switch (e.which) {
+ // match z or Z
+ case 122:
+ case 90:
+ if ( e.ctrlKey ) { // todo: command-key support for os x
+ // ctrl-z: undo
+ undo();
+ break;
+ }
+ zoomed = !zoomed;
+ if (zoomed) {
+ view.zoomMaximum();
+ } else {
+ view.zoomFit();
+ }
+ break;
+ case 89: // y
+ if (e.ctrlKey) redo();
+ case 46: // delete
+ // TODO: make this work with backspace without triggering the default (prev page) behavior
+ //case 8: // backspace
+ $('button#delete').click();
+ break;
+ default:
+ return true;
}
+ e.preventDefault();
+ return false;
});
this.$('button#help').click(function(){
@@ -726,29 +695,23 @@ $(function($) {
$('button#save').click( function() {
var button = $(this);
button.data('original-text', button.text());
- button.disabled = true;
overlay.warp({
success: function(model, response) {
- button.disabled = false;
- button.text("WARPED");
- _.delay(function(){button.text(button.data('original-text'));}, 1000);
$('input#show_preview').attr('checked', true).change();
- },
- error: function(model, response) {
- button.disabled = false;
- button.text("FAILED");
- _.delay(function(){button.text("save");}, 1000);
- },
+ }
});
});
var saveStatus = $('#saveStatus');
this.model.on('before_warp', function(){
- saveStatus.text(saveStatus.data('saving-text'));
+ //saveStatus.text(saveStatus.data('saving-text'));
+ saveStatus.html('<img src="/static/geocamTiePoint/images/loading.gif">');
}).on('warp_success', function(){
saveStatus.text(saveStatus.data('saved-text'));
- }).on('warp_error', function(){
- saveStatus.text(saveStatus.data('save-error'));
+ }).on('warp_server_error', function(){
+ saveStatus.html($('<span class="error">').text(saveStatus.data('server-error')));
+ }).on('warp_server_unreachable', function(){
+ saveStatus.html($('<span class="error">').text(saveStatus.data('server-unreachable')));
});
$('button#export').click(function() {
@@ -824,22 +787,27 @@ $(function($) {
}); // end SplitOverlayView
+ // FIX: requirements text hard-coded, should auto-update based on settings
+ var importRequirementsText = '[Size < 2 MB. Acceptable formats: JPEG, PDF, PNG, and others]';
+
app.views.NewOverlayView = app.views.View.extend({
template:
'<div id="new_overlay_view">'+
- '<h3>Create a New Overlay</h3>'+
+ '<h3>Create a New Overlay: Import Overlay Image</h3>'+
'<ul class="nav nav-tabs" id="formTabs">'+
' <li class="active" data-target="#fileUpload"><a href="#fileUpload">Upload</a></li>'+
- ' <li data-target="#ulrSubmit"><a href="#urlSubmit">URL</a></li>'+
+ ' <li data-target="#urlSubmit"><a href="#urlSubmit">From a URL</a></li>'+
'</ul>'+
' '+
'<div class="tab-content">'+
'<div class="tab-pane active" id="fileUpload">'+
'<form encytype="multipart/form-data" id="overlayUploadForm">'+
'<div id="uploadControlGroup" class="control-group">'+
- '<label>Local File</label>'+
- '<input type="file" name="file" id="newOverlayFile" />'+
+ '<label>Choose an image to upload' +
+ '<span class="import-requirements">' + importRequirementsText + '</span>' +
+ '</label>'+
+ '<div><input type="file" name="file" id="newOverlayFile" /></div>'+
'<input class="btn newOverlayFormSubmitButton" type="button" value="Upload" />'+
window.csrf_token +
'</div>'+
@@ -848,7 +816,10 @@ $(function($) {
'<div class="tab-pane" id="urlSubmit">'+
'<form encytype="multipart/form-data" id="overlayUrlForm">'+
'<div id="uploadControlGroup" class="control-group">'+
- '<label>Image URL</label> <input type="text" id="imageUrl" style="width: 98%"/>'+
+ '<label>Image URL' +
+ '<span class="import-requirements">' + importRequirementsText + '</span>' +
+ '</label>' +
+ '<input type="text" id="imageUrl" style="width: 98%"/>'+
'<input class="btn newOverlayFormSubmitButton" type="button" value="Submit" />'+
window.csrf_token +
'</div>'+
@@ -1019,11 +990,11 @@ $(function($) {
_.bindAll(this);
},
- template: '<h1>Export Overlay {{name}}</h1>'+
+ template: '<h1>Share Overlay {{name}}</h1>'+
'{{#if alignedTilesUrl}}' +
'<div id="simple_viewer">' +
'<a href="/overlay/{{key}}/simpleViewer_{{nospecials name}}.html" target="simpleViewer">' +
- 'View example code for displaying your overlay in any Google Maps API map' +
+ 'View a web page displaying your aligned overlay that you can download and serve from your web site' +
'</a></div>' +
'{{/if}}' +
'{{#if exportUrl}}'+
View
20 geocamTiePoint/static/geocamTiePoint/js/maputils.js
@@ -80,26 +80,26 @@ $(function($) {
return marker;
};
- maputils.locationSearchBar = function (search_bar, mapG) {
+ maputils.locationSearchBar = function (search_bar, map) {
// expecting search_bar to either be a selector string or a jquery object.
var input = _.isString(search_bar) ? $(search_bar)[0] : search_bar[0];
- var autoComplete = new google.maps.places.Autocomplete(input);
+ var autoComplete = new google.maps.places.SearchBox(input);
- autoComplete.bindTo('bounds', mapG);
+ autoComplete.bindTo('bounds', map);
var infoWindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
- map: mapG
+ map: map
});
- google.maps.event.addListener(autoComplete, 'place_changed', function() {
+ google.maps.event.addListener(autoComplete, 'places_changed', function() {
infoWindow.close();
- var place = autoComplete.getPlace();
+ var place = autoComplete.getPlaces()[0];
if (place.geometry.viewport) {
- mapG.fitBounds(place.geometry.viewport);
+ map.fitBounds(place.geometry.viewport);
} else {
- mapG.setCenter(place.geometry.location);
- mapG.setZoom(17);
+ map.setCenter(place.geometry.location);
+ map.setZoom(17);
}
var address = '';
@@ -115,7 +115,7 @@ $(function($) {
infoWindow.setContent('<div><strong>' + place.name + '</strong><br>' +
address + '</div>');
- infoWindow.open(mapG, marker);
+ infoWindow.open(map, marker);
});
};
View
152 geocamTiePoint/static/geocamTiePoint/js/overlay-preview.js
@@ -1,152 +0,0 @@
-// __BEGIN_LICENSE__
-// Copyright (C) 2008-2010 United States Government as represented by
-// the Administrator of the National Aeronautics and Space Administration.
-// All Rights Reserved.
-// __END_LICENSE__
-
-var tileSize = 256;
-var offset = 3;
-var opac = 0.6;
-var OPACITY_MAX_PIXELS = 57;
-var imageOverlay;
-
-function getTransformedImageTileUrl(coord, zoom) {
- var normalizedCoord = getNormalizedCoord(coord, zoom);
-
- if (!normalizedCoord)
- return null;
-
- return fillTemplate(overlay.alignedTilesUrl,
- {zoom: zoom,
- x: normalizedCoord.x,
- y: normalizedCoord.y});
-}
-
-var transformedImageMapTypeOptions = null;
-
-var transformedImageMapType = null;
-
-var map;
-
-function initialize() {
- // find max zoom
- var maxZoom = 0; var offset = 3;
- if (overlay.imageSize[0] > overlay.imageSize[1]) {
- maxZoom = Math.ceil(Math.log(overlay.imageSize[0] / tileSize, 2)) +
- offset;
- } else {
- maxZoom = Math.ceil(Math.log(overlay.imageSize[1] / tileSize, 2)) +
- offset;
- }
-
- transformedImageMapTypeOptions = {
- getTileUrl: getTransformedImageTileUrl,
- tileSize: new google.maps.Size(tileSize, tileSize),
- maxZoom: maxZoom,
- minZoom: offset,
- radius: 1738000,
- opacity: parseFloat(opac),
- name: 'transformed-image-map'
- };
-
- transformedImageMapType = (new google.maps.ImageMapType
- (transformedImageMapTypeOptions));
-
- var mapOptions = {
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- map = new google.maps.Map(document.getElementById('map_canvas'),
- mapOptions);
- fitNamedBounds(overlay.bounds);
-
- //insert the overlay map as first overlay map type at position 0
- map.overlayMapTypes.insertAt(0, transformedImageMapType);
-
- var initialOpacity = 60;
- // imageOverlay = new CustomTileOverlay(map,initialOpacity);
- // imageOverlay.show();
-
- createOpacityControl(map, initialOpacity);
-}
-
-function fitNamedBounds(b) {
- var bounds = (new google.maps.LatLngBounds
- (new google.maps.LatLng(b.south, b.west),
- new google.maps.LatLng(b.north, b.east)));
- map.fitBounds(bounds);
-}
-
-//set up a transparency slider
-function createOpacityControl(map, opacity) {
- var sliderImageUrl = settings.STATIC_URL +
- 'geocamTiePoint/images/opacity-slider3d6.png';
-
- // Create main div to hold the control.
- var opacityDiv = document.createElement('DIV');
- (opacityDiv.setAttribute
- ('style',
- 'margin: 5px;' +
- ' overflow-x: hidden;' +
- ' overflow-y: hidden;' +
- ' background: url(' + sliderImageUrl + ') no-repeat;' +
- ' width: 71px;' +
- ' height: 21px;' +
- ' cursor: pointer;'));
-
- // Create knob
- var opacityKnobDiv = document.createElement('DIV');
- (opacityKnobDiv.setAttribute
- ('style',
- 'padding: 0;' +
- ' margin: 0;' +
- ' overflow-x: hidden;' +
- ' overflow-y: hidden;' +
- ' background: url(' + sliderImageUrl + ') no-repeat -71px 0;' +
- ' width: 14px;' +
- ' height: 21px;'));
- opacityDiv.appendChild(opacityKnobDiv);
-
- var opacityCtrlKnob = new ExtDraggableObject(opacityKnobDiv, {
- restrictY: true,
- container: opacityDiv
- });
-
- google.maps.event.addListener(opacityCtrlKnob, 'dragend', function() {
- setOpacity(opacityCtrlKnob.valueX());
- });
-
- google.maps.event.addDomListener(opacityDiv, 'click', function(e) {
- var left = findPosLeft(this);
- var x = e.pageX - left - 5;
- opacityCtrlKnob.setValueX(x);
- setOpacity(x);
- });
-
- map.controls[google.maps.ControlPosition.TOP_RIGHT].push(opacityDiv);
- var initialValue = OPACITY_MAX_PIXELS / (100 / opacity);
- opacityCtrlKnob.setValueX(initialValue);
- setOpacity(initialValue);
-}
-
-function setOpacity(pixelX) {
- // pixelX in range 0 to OPACITY_MAX_PIXELS
- var opacityPercent = (100 / OPACITY_MAX_PIXELS) * pixelX;
-
- if (opacityPercent < 0) opacityPercent = 0;
- if (opacityPercent > 100) opacityPercent = 100;
-
- //console.log("opacity: " + opacityPercent);
- transformedImageMapType.setOpacity(opacityPercent / 100.0);
-}
-
-function findPosLeft(obj) {
- var curleft = 0;
- if (obj.offsetParent) {
- do {
- curleft += obj.offsetLeft;
- } while (obj = obj.offsetParent);
- return curleft;
- }
- return undefined;
-}
-
View
490 geocamTiePoint/static/geocamTiePoint/js/overlay-view.js
@@ -1,490 +0,0 @@
-// __BEGIN_LICENSE__
-// Copyright (C) 2008-2010 United States Government as represented by
-// the Administrator of the National Aeronautics and Space Administration.
-// All Rights Reserved.
-// __END_LICENSE__
-
-var mapG;
-var imageMapG;
-
-var imageMarkersG = [];
-var mapMarkersG = [];
-
-var imageCoordsG = [];
-var mapCoordsG = [];
-
-var saveButtonTimeoutG = null;
-var otherSaveButtonTimeoutG = null;
-var warpButtonTimeoutG = null;
-var otherWarpButtonTimeoutG = null;
-
-var markerIconG = (
- new google.maps.MarkerImage
- ('http://maps.gstatic.com/mapfiles/markers2/marker_blank.png'));
-
-var draggingG = false;
-
-function getImageTileUrl(coord, zoom) {
- var normalizedCoord = getNormalizedCoord(coord, zoom);
-
- if (!normalizedCoord)
- return null;
-
- return fillTemplate(overlay.unalignedTilesUrl,
- {zoom: zoom,
- x: normalizedCoord.x,
- y: normalizedCoord.y});
-}
-
-function initialize() {
- initializeCoords();
- initializeMap();
- initializeImage();
- initializeSearchBar();
-
- setState(overlay);
-}
-
-function initializeSearchBar() {
- var input = document.getElementById('searchTextField');
- var autoComplete = new google.maps.places.Autocomplete(input);
-
- autoComplete.bindTo('bounds', mapG);
-
- var infoWindow = new google.maps.InfoWindow();
- var marker = new google.maps.Marker({
- map: mapG
- });
-
- google.maps.event.addListener(autoComplete, 'place_changed', function() {
- infoWindow.close();
- var place = autoComplete.getPlace();
- if (place.geometry.viewport) {
- mapG.fitBounds(place.geometry.viewport);
- } else {
- mapG.setCenter(place.geometry.location);
- mapG.setZoom(17);
- }
-
- var address = '';
- if (place.address_components) {
- address = [(place.address_components[0] &&
- place.address_components[0].short_name || ''),
- (place.address_components[1] &&
- place.address_components[1].short_name || ''),
- (place.address_components[2] &&
- place.address_components[2].short_name || '')
- ].join(' ');
- }
-
- infoWindow.setContent('<div><strong>' + place.name + '</strong><br>' +
- address + '</div>');
- infoWindow.open(mapG, marker);
- });
-}
-
-function initializeMap() {
- var mapOptions = {
- zoom: 6,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
-
- mapG = new google.maps.Map(document.getElementById('map_canvas'),
- mapOptions);
-
- if (overlay.bounds) {
- fitNamedBounds(overlay.bounds, mapG);
- } else if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function(position) {
- var pos = new google.maps.LatLng(position.coords.latitude,
- position.coords.longitude);
- mapG.setCenter(pos);
- }, function() {
- handleNoGeolocation(true);
- });
- } else {
- // browser doesn't support geolocation
- handleNoGeolocation(false);
- }
-
- google.maps.event.addListener(mapG, 'click', handleMapClick);
-}
-
-function getLabeledMarker(latLng, index, map,
- dragEndHandler,
- rightClickHandler) {
- var markerOpts = {
- title: '' + (index + 1),
- draggable: true,
- position: latLng,
- map: map,
- icon: markerIconG,
- labelContent: '' + (index + 1),
- labelAnchor: new google.maps.Point(20, 30),
- labelClass: 'labels',
- raiseOnDrag: false
- };
- var marker = new MarkerWithLabel(markerOpts);
-
- // add handlers
- google.maps.event.addListener(marker, 'dragstart', function(event) {
- draggingG = true;
- });
- google.maps.event.addListener(marker, 'dragend', function(i) {
- return function(event) {
- dragEndHandler(i, event);
- setTimeout(function() {draggingG = false;}, 100);
- }
- }(index));
- (google.maps.event.addListener
- (marker, 'rightclick', function(i) {
- return function(event) {
- rightClickHandler(i, event);
- }
- }(index)));
-
- return marker;
-}
-
-function getLabeledImageMarker(latLng, index) {
- return getLabeledMarker(latLng, index,
- imageMapG,
- handleImageMarkerDragEnd,
- handleImageMarkerRightClick);
-}
-
-function getLabeledMapMarker(latLng, index) {
- return getLabeledMarker(latLng, index,
- mapG,
- handleMapMarkerDragEnd,
- handleMapMarkerRightClick);
-}
-
-function initializeImage() {
- var mapOptions = {
- streetViewControl: false,
- backgroundColor: 'rgb(0,0,0)',
- mapTypeControlOptions: {
- mapTypeId: ['image-map']
- }
- };
-
- imageMapG = new google.maps.Map(document.getElementById('image_canvas'),
- mapOptions);
-
- // initialize viewport to contain image
- var w = overlay.imageSize[0];
- var h = overlay.imageSize[1];
- var sw = pixelsToLatLon({x: 0, y: h});
- var ne = pixelsToLatLon({x: w, y: 0});
- imageMapG.fitBounds(new google.maps.LatLngBounds(sw, ne));
-
- var maxZoom = (maxZoom0G +
- settings.GEOCAM_TIE_POINT_ZOOM_LEVELS_PAST_OVERLAY_RESOLUTION);
- var imageMapTypeOptions = {
- getTileUrl: getImageTileUrl,
- tileSize: new google.maps.Size(TILE_SIZE, TILE_SIZE),
- maxZoom: maxZoom,
- minZoom: MIN_ZOOM_OFFSET,
- radius: 1738000,
- name: 'image-map'
- };
- var imageMapType = new google.maps.ImageMapType(imageMapTypeOptions);
-
- imageMapG.mapTypes.set('image-map', imageMapType);
- imageMapG.setMapTypeId('image-map');
-
- google.maps.event.addListener(imageMapG, 'click', handleImageClick);
-}
-
-function handleNoGeolocation(errorFlag) {
- fitNamedBounds(settings.GEOCAM_TIE_POINT_DEFAULT_MAP_VIEWPORT);
-}
-
-function handleImageClick(event) {
- if (draggingG) return;
- actionPerformed();
- var latLng = event.latLng;
- var coord = latLonToPixel(latLng);
- var index = imageMarkersG.length;
-
- var marker = getLabeledImageMarker(latLng, index);
-
- imageMarkersG.push(marker);
- imageCoordsG.push(coord);
-}
-
-function handleMapClick(event) {
- if (draggingG) return;
- actionPerformed();
- var latLng = event.latLng;
- var coord = latLonToMeters(latLng);
- var index = mapMarkersG.length;
-
- var marker = getLabeledMapMarker(latLng, index);
-
- mapMarkersG.push(marker);
- mapCoordsG.push(coord);
-}
-
-function handleImageMarkerDragEnd(markerIndex, event) {
- actionPerformed();
- var coords = latLonToPixel(event.latLng);
- imageCoordsG[markerIndex] = coords;
-}
-
-function handleMapMarkerDragEnd(markerIndex, event) {
- actionPerformed();
- var coords = latLonToMeters(event.latLng);
- mapCoordsG[markerIndex] = coords;
-}
-
-function handleImageMarkerRightClick(markerIndex, event) {
- return; // this doesn't really work right now
- actionPerformed();
- imageCoordsG[markerIndex] = null;
- imageMarkersG[markerIndex].setMap(null);
- imageMarkersG[markerIndex] = null;
-}
-
-function handleMapMarkerRightClick(markerIndex, event) {
- return; // this doesn't really work right now
- actionPerformed();
- mapCoordsG[markerIndex] = null;
- mapMarkersG[markerIndex].setMap(null);
- mapMarkersG[markerIndex] = null;
-}
-
-function warpButtonClicked(key) {
- if (warpButtonTimeoutG != null)
- clearTimeout(warpButtonTimeoutG);
- if (otherWarpButtonTimeoutG != null)
- clearTimeout(otherWarpButtonTimeoutG);
- var warpButton = $('#warp_button')[0];
- warpButton.disabled = true;
- warpButton.value = 'warping...';
- $.post(overlay.url.replace('.json', '/warp'))
- .success(function(data, status, khr) {
- warpButton.disabled = false;
- warpButton.value = 'success!';
- warpButtonTimeoutG = setTimeout(function() {
- warpButton.value = 'warp';
- }, 3000);
- })
- .error(function(xhr, status, error) {
- warpButton.disabled = false;
- warpButton.value = 'warp';
- alert('Error occurred during warping: ' + error);
- });
- otherWarpButtonTimeoutG = setTimeout(function() {
- if (warpButton.disabled) {
- warpButton.value = 'still warping...';
- warpButton.disabled = false;
- }
- }, 10000);
-}
-
-function save(serverState) {
- // set the global 'overlay' variable to the latest sever state
- overlay = serverState;
-
- // getState() overwrites overlay.points and returns overlay. this
- // has the effect of merging the server state with the client-side
- // points
- var state = getState();
-
- // solve for the transform
- if (imageCoordsG.length >= 2) {
- state.transform = (geocamTiePoint.transform
- .getTransform(state.points)
- .toDict());
- } else {
- state.transform = null;
- }
-
- var saveButton = $('#save_button')[0];
- $.post(overlay.url, JSON.stringify(state))
- .success(function(data, status, xhr) {
- saveButton.value = 'success!';
- saveButton.disabled = false;
- saveButtonTimeoutG = setTimeout(function() {
- saveButton.value = 'save';
- }, 3000);
- })
- .error(function(xhr, status, error) {
- saveButton.value = 'save';
- saveButton.disabled = false;
- alert('Error occurred while saving: ' + error);
- });
-}
-
-function saveButtonClicked() {
- if (saveButtonTimeoutG != null)
- clearTimeout(saveButtonTimeoutG);
- if (otherSaveButtonTimeoutG != null)
- clearTimeout(otherSaveButtonTimeoutG);
-
- saveButton = $('#save_button')[0];
- if (mapCoordsG.length != imageCoordsG.length) {
- var diff = mapCoordsG.length - imageCoordsG.length;
- if (diff > 0) // need to add points to image
- saveButton.value = 'Add ' + diff + ' to image';
- else
- saveButton.value = 'Add ' + (-diff) + ' to map';
- saveButtonTimeoutG = setTimeout(function() {
- saveButton.value = 'save';
- }, 3000);
- return;
- }
-
- saveButton.disabled = true;
- saveButton.value = 'saving...';
- $.getJSON(overlay.url)
- .success(save)
- .error(function(xhr, status, error) {
- saveButton.value = 'save';
- saveButton.disabled = false;
- alert('Error occurred while saving: ' + error);
- });
- otherSaveButtonTimeoutG = setTimeout(function() {
- if (saveButton.disabled) {
- saveButton.value = 'still saving...';
- saveButton.disabled = false;
- }
- }, 3000);
-}
-
-function resetButtonClicked() {
- actionPerformed();
- reset();
-}
-
-function reset() {
- $.each(imageMarkersG, function(i, marker) {
- if (marker.setMap) {
- marker.setMap(null);
- }
- });
- imageMarkersG = [];
- imageCoordsG = [];
-
- $.each(mapMarkersG, function(i, marker) {
- if (marker.setMap) {
- marker.setMap(null);
- }
- });
- mapMarkersG = [];
- mapCoordsG = [];
-}
-
-function getState() {
- var state = overlay;
-
- // state.name = $('#title')[0].value;
-
- var points = [];
- var n = Math.max(imageCoordsG.length, mapCoordsG.length);
- for (var i = 0; i < n; i++) {
- var coords = [];
-
- if (i < mapCoordsG.length) {
- coords[0] = mapCoordsG[i].x;
- coords[1] = mapCoordsG[i].y;
- } else {
- coords[0] = null;
- coords[1] = null;
- }
-
- if (i < imageCoordsG.length) {
- coords[2] = imageCoordsG[i].x;
- coords[3] = imageCoordsG[i].y;
- } else {
- coords[2] = null;
- coords[3] = null;
- }
-
- points.push(coords);
- }
- state.points = points;
-
- return state;
-}
-
-function setState(state) {
- reset(); // clear state
-
- if (state.points) {
- mapMarkersG = [];
- mapCoordsG = [];
-
- imageMarkersG = [];
- imageCoordsG = [];
-
- for (var index = 0; index < state.points.length; index++) {
- var point = state.points[index];
-
- var meters = {
- x: point[0],
- y: point[1]
- };
- if (meters.x != null && meters.y != null) {
- var latLng = metersToLatLon(meters);
- var marker = getLabeledMapMarker(latLng, index);
- mapMarkersG.push(marker);
- mapCoordsG.push(meters);
- }
-
- var pixels = {
- x: point[2],
- y: point[3]
- };
- if (pixels.x != null && pixels.y != null) {
- var latLng = pixelsToLatLon(pixels);
- var marker = getLabeledImageMarker(latLng, index);
- imageMarkersG.push(marker);
- imageCoordsG.push(pixels);
- }
- }
- }
-}
-
-function debugFit() {
- var transform = geocamTiePoint.transform;
- var spl = transform.splitPoints(overlay.points);
- var toPts = spl[0];
- var fromPts = spl[1];
- var tform = transform.getTransform(overlay.points);
- var toPtsApprox = transform.forwardPoints(tform, fromPts);
- var diff = toPtsApprox.subtract(toPts);
- console.log('tform:\n' + JSON.stringify(tform));
- console.log('toPts:\n' + toPts.toString());
- console.log('toPtsApprox:\n' + toPtsApprox.toString());
- console.log('diff:\n' + diff.toString());
- console.log('err:' + diff.meanNorm());
-
- var greenIcon = (new google.maps.MarkerImage
- ('http://maps.google.com/mapfiles/ms/icons/green.png'));
- var n = overlay.points.length;
- for (var i = 0; i < n; i++) {
- var meterCoords = {
- x: toPtsApprox.values[0][i],
- y: toPtsApprox.values[1][i]
- };
- console.log(JSON.stringify(meterCoords));
- var latlng = metersToLatLon(meterCoords);
- console.log(JSON.stringify(latlng));
- var markerOpts = {
- title: '' + (i + 1),
- draggable: true,
- position: latlng,
- map: mapG,
- icon: greenIcon,
- labelContent: '' + (i + 1),
- labelAnchor: new google.maps.Point(20, 30),
- labelClass: 'labels'
- };
- var marker = new MarkerWithLabel(markerOpts);
- }
-
-}
-
View
519 geocamTiePoint/static/geocamTiePoint/js/uiDemo.js
@@ -1,519 +0,0 @@
-// __BEGIN_LICENSE__
-// Copyright (C) 2008-2010 United States Government as represented by
-// the Administrator of the National Aeronautics and Space Administration.
-// All Rights Reserved.
-// __END_LICENSE__
-
-var mapG;
-var imageMapG;
-
-var imageMarkersG = [];
-var mapMarkersG = [];
-
-var imageCoordsG = [];
-var mapCoordsG = [];
-
-var saveButtonTimeoutG = null;
-var otherSaveButtonTimeoutG = null;
-var warpButtonTimeoutG = null;
-var otherWarpButtonTimeoutG = null;
-
-var markerIconG = (
- new google.maps.MarkerImage
- ('http://maps.gstatic.com/mapfiles/markers2/marker_blank.png'));
-
-var draggingG = false;
-var previewOverlayG = null;
-
-function getImageTileUrl(coord, zoom) {
- var normalizedCoord = getNormalizedCoord(coord, zoom);
-
- if (!normalizedCoord)
- return null;
-
- return fillTemplate(overlay.unalignedTilesUrl,
- {zoom: zoom,
- x: normalizedCoord.x,
- y: normalizedCoord.y});
-}
-
-function initialize() {
- initializeCoords();
- initializeMap();
- initializeImage();
- initializeSearchBar();
- initializeDraggableOverlay();
-
- setState(overlay);
-}
-
-function initializeDraggableOverlay() {
- var imageUrl = '/overlay/' + overlay.key + '/image.png';
- var alignTransform = new Matrix(3, 3, overlay.transform.matrix);
- var opts = {}; // fill me in
- previewOverlayG =
- new geocamTiePoint.DraggableOverlay(imageUrl, alignTransform,
- opts);
- previewOverlayG.setMap(mapG);
-}
-
-function initializeSearchBar() {
- var input = document.getElementById('searchTextField');
- var autoComplete = new google.maps.places.Autocomplete(input);
-
- autoComplete.bindTo('bounds', mapG);
-
- var infoWindow = new google.maps.InfoWindow();
- var marker = new google.maps.Marker({
- map: mapG
- });
-
- google.maps.event.addListener(autoComplete, 'place_changed', function() {
- infoWindow.close();
- var place = autoComplete.getPlace();
- if (place.geometry.viewport) {
- mapG.fitBounds(place.geometry.viewport);
- } else {
- mapG.setCenter(place.geometry.location);
- mapG.setZoom(17);
- }
-
- var address = '';
- if (place.address_components) {
- address = [(place.address_components[0] &&
- place.address_components[0].short_name || ''),
- (place.address_components[1] &&
- place.address_components[1].short_name || ''),
- (place.address_components[2] &&
- place.address_components[2].short_name || '')
- ].join(' ');
- }
-
- infoWindow.setContent('<div><strong>' + place.name + '</strong><br>' +
- address + '</div>');
- infoWindow.open(mapG, marker);
- });
-}
-
-function initializeMap() {
- var mapOptions = {
- zoom: 6,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
-
- mapG = new google.maps.Map(document.getElementById('map_canvas'),
- mapOptions);
-
- if (overlay.bounds) {
- fitNamedBounds(overlay.bounds, mapG);
- } else if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function(position) {
- var pos = new google.maps.LatLng(position.coords.latitude,
- position.coords.longitude);
- mapG.setCenter(pos);
- }, function() {
- handleNoGeolocation(true);
- });
- } else {
- // browser doesn't support geolocation
- handleNoGeolocation(false);
- }
-
- google.maps.event.addListener(mapG, 'click', handleMapClick);
-}
-
-function getLabeledMarker(latLng, index, map,
- dragEndHandler,
- rightClickHandler) {
- var markerOpts = {
- title: '' + (index + 1),
- draggable: true,
- position: latLng,
- map: map,
- icon: markerIconG,
- labelContent: '' + (index + 1),
- labelAnchor: new google.maps.Point(20, 30),
- labelClass: 'labels',
- raiseOnDrag: false
- };
- var marker = new MarkerWithLabel(markerOpts);
-
- // add handlers
- google.maps.event.addListener(marker, 'dragstart', function(event) {
- draggingG = true;
- });
- google.maps.event.addListener(marker, 'dragend', function(i) {
- return function(event) {
- dragEndHandler(i, event);
- setTimeout(function() {draggingG = false;}, 100);
- }
- }(index));
- (google.maps.event.addListener
- (marker, 'rightclick', function(i) {
- return function(event) {
- rightClickHandler(i, event);
- }
- }(index)));
-
- return marker;
-}
-
-function getLabeledImageMarker(latLng, index) {
- return getLabeledMarker(latLng, index,
- imageMapG,
- handleImageMarkerDragEnd,
- handleImageMarkerRightClick);
-}
-
-function getLabeledMapMarker(latLng, index) {
- return getLabeledMarker(latLng, index,
- mapG,
- handleMapMarkerDragEnd,
- handleMapMarkerRightClick);
-}
-
-function initializeImage() {
- var mapOptions = {
- streetViewControl: false,
- backgroundColor: 'rgb(0,0,0)',
- mapTypeControlOptions: {
- mapTypeId: ['image-map']
- }
- };
-
- imageMapG = new google.maps.Map(document.getElementById('image_canvas'),
- mapOptions);
-
- // initialize viewport to contain image
- var w = overlay.imageSize[0];
- var h = overlay.imageSize[1];
- var sw = pixelsToLatLon({x: 0, y: h});
- var ne = pixelsToLatLon({x: w, y: 0});
- imageMapG.fitBounds(new google.maps.LatLngBounds(sw, ne));
-
- var maxZoom = (maxZoom0G +
- settings.GEOCAM_TIE_POINT_ZOOM_LEVELS_PAST_OVERLAY_RESOLUTION);
- var imageMapTypeOptions = {
- getTileUrl: getImageTileUrl,
- tileSize: new google.maps.Size(TILE_SIZE, TILE_SIZE),
- maxZoom: maxZoom,
- minZoom: MIN_ZOOM_OFFSET,
- radius: 1738000,
- name: 'image-map'
- };
- var imageMapType = new google.maps.ImageMapType(imageMapTypeOptions);
-
- imageMapG.mapTypes.set('image-map', imageMapType);
- imageMapG.setMapTypeId('image-map');
-
- google.maps.event.addListener(imageMapG, 'click', handleImageClick);
-}
-
-function handleNoGeolocation(errorFlag) {
- fitNamedBounds(settings.GEOCAM_TIE_POINT_DEFAULT_MAP_VIEWPORT);
-}
-
-function handleImageClick(event) {
- if (draggingG) return;
- actionPerformed();
- var latLng = event.latLng;
- var coord = latLonToPixel(latLng);
- var index = imageMarkersG.length;
-
- var marker = getLabeledImageMarker(latLng, index);
-
- imageMarkersG.push(marker);
- imageCoordsG.push(coord);
-}
-
-function handleMapClick(event) {
- if (draggingG) return;
- actionPerformed();
- var latLng = event.latLng;
- var coord = latLonToMeters(latLng);
- var index = mapMarkersG.length;
-
- var marker = getLabeledMapMarker(latLng, index);
-
- mapMarkersG.push(marker);
- mapCoordsG.push(coord);
-}
-
-function handleImageMarkerDragEnd(markerIndex, event) {
- actionPerformed();
- var coords = latLonToPixel(event.latLng);
- imageCoordsG[markerIndex] = coords;
-
- updateAlignment();
-}
-
-function handleMapMarkerDragEnd(markerIndex, event) {
- actionPerformed();
- var coords = latLonToMeters(event.latLng);
- mapCoordsG[markerIndex] = coords;
-
- updateAlignment();
-}
-
-function handleImageMarkerRightClick(markerIndex, event) {
- return; // this doesn't really work right now
- actionPerformed();
- imageCoordsG[markerIndex] = null;
- imageMarkersG[markerIndex].setMap(null);
- imageMarkersG[markerIndex] = null;
-}
-
-function handleMapMarkerRightClick(markerIndex, event) {
- return; // this doesn't really work right now
- actionPerformed();
- mapCoordsG[markerIndex] = null;
- mapMarkersG[markerIndex].setMap(null);
- mapMarkersG[markerIndex] = null;
-}
-
-function warpButtonClicked(key) {
- if (warpButtonTimeoutG != null)
- clearTimeout(warpButtonTimeoutG);
- if (otherWarpButtonTimeoutG != null)
- clearTimeout(otherWarpButtonTimeoutG);
- var warpButton = $('#warp_button')[0];
- warpButton.disabled = true;
- warpButton.value = 'warping...';
- $.post(overlay.url.replace('.json', '/warp'))
- .success(function(data, status, khr) {
- warpButton.disabled = false;
- warpButton.value = 'success!';
- warpButtonTimeoutG = setTimeout(function() {
- warpButton.value = 'warp';
- }, 3000);
- })
- .error(function(xhr, status, error) {
- warpButton.disabled = false;
- warpButton.value = 'warp';
- alert('Error occurred during warping: ' + error);
- });
- otherWarpButtonTimeoutG = setTimeout(function() {
- if (warpButton.disabled) {
- warpButton.value = 'still warping...';
- warpButton.disabled = false;
- }
- }, 10000);
-}
-
-function updateAlignment() {
- getState();
- redrawPreviewOverlay();
-}
-
-function redrawPreviewOverlay() {
- if (imageCoordsG.length >= 2) {
- previewOverlayG.alignTransform =
- new Matrix(3, 3, overlay.transform.matrix);
- previewOverlayG.draw();
- }
-}
-
-function save(serverState) {
- // set the global 'overlay' variable to the latest sever state
- overlay = serverState;
-
- // getState() overwrites overlay.points and returns overlay. this
- // has the effect of merging the server state with the client-side
- // points
- var state = getState();
-
- var saveButton = $('#save_button')[0];
- $.post(overlay.url, JSON.stringify(state))
- .success(function(data, status, xhr) {
- saveButton.value = 'success!';
- saveButton.disabled = false;
- saveButtonTimeoutG = setTimeout(function() {
- saveButton.value = 'save';
- }, 3000);
- })
- .error(function(xhr, status, error) {
- saveButton.value = 'save';
- saveButton.disabled = false;
- alert('Error occurred while saving: ' + error);
- });
-}
-
-function saveButtonClicked() {
- if (saveButtonTimeoutG != null)
- clearTimeout(saveButtonTimeoutG);
- if (otherSaveButtonTimeoutG != null)
- clearTimeout(otherSaveButtonTimeoutG);
-
- saveButton = $('#save_button')[0];
- if (mapCoordsG.length != imageCoordsG.length) {
- var diff = mapCoordsG.length - imageCoordsG.length;
- if (diff > 0) // need to add points to image
- saveButton.value = 'Add ' + diff + ' to image';
- else
- saveButton.value = 'Add ' + (-diff) + ' to map';
- saveButtonTimeoutG = setTimeout(function() {
- saveButton.value = 'save';
- }, 3000);
- return;
- }
-
- saveButton.disabled = true;
- saveButton.value = 'saving...';
- $.getJSON(overlay.url)
- .success(save)
- .error(function(xhr, status, error) {
- saveButton.value = 'save';
- saveButton.disabled = false;
- alert('Error occurred while saving: ' + error);
- });
- otherSaveButtonTimeoutG = setTimeout(function() {
- if (saveButton.disabled) {
- saveButton.value = 'still saving...';
- saveButton.disabled = false;
- }
- }, 3000);
-}
-
-function resetButtonClicked() {
- actionPerformed();
- reset();
-}
-
-function reset() {
- $.each(imageMarkersG, function(i, marker) {
- if (marker.setMap) {
- marker.setMap(null);
- }
- });
- imageMarkersG = [];
- imageCoordsG = [];
-
- $.each(mapMarkersG, function(i, marker) {
- if (marker.setMap) {
- marker.setMap(null);
- }
- });
- mapMarkersG = [];
- mapCoordsG = [];
-}
-
-function getState() {
- var state = overlay;
-
- // state.name = $('#title')[0].value;
-
- var points = [];
- var n = Math.max(imageCoordsG.length, mapCoordsG.length);
- for (var i = 0; i < n; i++) {
- var coords = [];
-
- if (i < mapCoordsG.length) {
- coords[0] = mapCoordsG[i].x;
- coords[1] = mapCoordsG[i].y;
- } else {
- coords[0] = null;
- coords[1] = null;
- }
-
- if (i < imageCoordsG.length) {
- coords[2] = imageCoordsG[i].x;
- coords[3] = imageCoordsG[i].y;
- } else {
- coords[2] = null;
- coords[3] = null;
- }
-
- points.push(coords);
- }
- state.points = points;
-
- if (state.points.length >= 2) {
- state.transform = calculateAlignmentModel(state.points);
- } else {
- state.transform = {
- 'type': '',
- 'matrix': []
- };
- }
-
- return state;
-}
-
-function setState(state) {
- reset(); // clear state
-
- if (!state.points) {
- state.points = [];
- }
-
- mapMarkersG = [];
- mapCoordsG = [];
-
- imageMarkersG = [];
- imageCoordsG = [];
-
- for (var index = 0; index < state.points.length; index++) {
- var point = state.points[index];
-
- var meters = {
- x: point[0],
- y: point[1]
- };
- if (meters.x != null && meters.y != null) {
- var latLng = metersToLatLon(meters);
- var marker = getLabeledMapMarker(latLng, index);
- mapMarkersG.push(marker);
- mapCoordsG.push(meters);
- }
-
- var pixels = {
- x: point[2],
- y: point[3]
- };
- if (pixels.x != null && pixels.y != null) {
- var latLng = pixelsToLatLon(pixels);
- var marker = getLabeledImageMarker(latLng, index);
- imageMarkersG.push(marker);
- imageCoordsG.push(pixels);
- }
- }
-
- overlay = state;
-
- redrawPreviewOverlay();
-}
-
-function debugFit() {
- var U = getProjectiveUMatrixFromPoints(overlay.points);
- var T = new Matrix(3, 3, overlay.transform.matrix);
- var V = getVMatrixFromPoints(overlay.points);
- var Vapprox = applyTransform(overlay.transform, overlay.points);
- var Verror = Vapprox.subtract(V);
- console.log('U:\n' + U.toString());
- console.log('T:\n' + T.toString());
- console.log('V:\n' + V.toString());
- console.log('Vapprox:\n' + Vapprox.toString());
- console.log('Verror:\n' + Verror.toString());
-
- var greenIcon = (new google.maps.MarkerImage
- ('http://maps.google.com/mapfiles/ms/icons/green.png'));
- var n = overlay.points.length;
- for (var i = 0; i < n; i++) {
- var meterCoords = {x: Vapprox.values[0][i], y: Vapprox.values[1][i]};
- console.log(meterCoords);
- var latlng = metersToLatLon(meterCoords);
- console.log(latlng);
- var markerOpts = {
- title: '' + (i + 1),
- draggable: true,
- position: latlng,
- map: mapG,
- icon: greenIcon,
- labelContent: '' + (i + 1),
- labelAnchor: new google.maps.Point(20, 30),
- labelClass: 'labels'
- };
- var marker = new MarkerWithLabel(markerOpts);
- }
-
-}
View
1  geocamTiePoint/templates/geocamTiePoint/backbone.html
@@ -19,6 +19,7 @@
// this line needs to be here otherwise views.js won't get it
window.csrf_token = "{% csrf_token %}";
</script>
+
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>
{% compressed_js "external" %}
View
69 geocamTiePoint/templates/geocamTiePoint/ember.html
@@ -1,69 +0,0 @@
-{% extends "base.html" %}
-{% load templatetag_handlebars %}
-
-{% block head %}
-{{ block.super }}
-<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
-{% block handlebars %}
- {% comment %}
- Handlebar templates go here. e.g.:
- {% tplhandlebars "tpl-infos" %}
- {{total}} {% trans "result(s)." %}
- <p>{% trans "Min" %}: {{min}}</p>
- <p>{% trans "Max" %}: {{max}}</p>
- {% endtplhandlebars %}
- {% endcomment %}
- {% include "geocamTiePoint/handlebars.html" %}
-{% endblock handlebars %}
-{% endblock %}
-
-{% block scripts %}
-{{ block.super }}
-<script type="text/javascript" src="/static/external/js/jquery-1.7.2.min.js"></script>
-<script type="text/javascript" src="/static/external/js/handlebars-1.0.0.beta.6.js"></script>
-<!--<script type="text/javascript" src="/static/external/js/ember-1.0.pre.min.js"></script>-->
-<script type="text/javascript" src="/static/external/js/ember-1.0.pre.js"></script>
-<script type="text/javascript" src="/static/external/js/ember-data.js"></script>
-
-<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>
-
-<script type="text/javascript" src="/static/geocamTiePoint/js/app.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/router.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/models.js"></script>
-
-<script type="text/javascript" src="/static/geocamTiePoint/js/util.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/views/AlignTiePoints.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/views/ChooseAlignmentMethod.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/views/EditInfo.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/views/NewMapOverlay.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/views/PlaceTiePoints.js"></script>
-<script type="text/javascript" src="/static/geocamTiePoint/js/views/ViewPage.js"></script>
-{% endblock scripts %}
-
-{% block header %}
- {{ block.super }}
-{% endblock header %}
-
-{% block contents %}
-<script type="text/x-handlebars" data-template-name="application">
-<h1>This is the Application Template</h1>
-{% verbatim %}
-{{outlet}}
-{% endverbatim %}
-</script>
-{% comment %}
-{% tplhandlebars "application" %}
- <h1>This is the Application Template</h1>
- {{outlet}}
-{% endtplhandlebars %}
-{% endcomment %}
-{% endblock contents %}
-
-{% block jsInit %}
-{{ block.super }}
-$(
- function() {
- App.initialize(App.Router.create());
- }
-);
-{% endblock jsInit %}
View
12 geocamTiePoint/templates/geocamTiePoint/simple-view.html
@@ -12,8 +12,16 @@
</style>
</head>
<div>
- <a href="#" onclick="window.location = 'view-source:' + window.location; return false;">View Source</a>
- - Copy and paste the JavaScript from this page into your own Google Maps API Map to display your overlay
+ You can save this web page and serve it from your own web site as an easy way
+ to share your overlay.
+</div>
+<div>
+ You can also cut and paste the JavaScript that loads this overlay into
+ any map built with the
+ <a href="https://developers.google.com/maps/documentation/javascript/tutorial">
+ Google Maps API</a>,
+ and you can use this technique to load multiple overlays at the same
+ time.
</div>
<div>
<b>MapFasten: {{ name }}</b>&nbsp;
View
3  geocamTiePoint/urls.py
@@ -79,9 +79,6 @@
{}, 'geocamTiePoint_overlayIdImageFileName'),
## New Client ##
- url(r'^ember/', 'ember',
- {}, 'geocamTiePoint_ember'),
-
url(r'^backbone/', 'backbone',
{}, 'geocamTiePoint_backbone'),
View
56 geocamTiePoint/views.py
@@ -67,14 +67,6 @@ def export_settings(export_vars=None):
return dumps(dict([(k, getattr(settings, k)) for k in export_vars]))
-def ember(request):
- if request.method == 'GET':
- return render_to_response('geocamTiePoint/ember.html', {},
- context_instance=RequestContext(request))
- else:
- return HttpResponseNotAllowed(['GET'])
-
-
@login_required
def backbone(request):
initial_overlays = Overlay.objects.order_by('pk')
@@ -132,6 +124,11 @@ def __init__(self, errors, *args, **kwargs):
errors = { "__all__": [errors] }
super(ErrorJSONResponse, self).__init__(json.dumps(errors), *args, status=400, content_type="application/json", **kwargs)
+
+def toMegaBytes(bytes):
+ return '%.1d' % (bytes / (1024 * 1024))
+
+
class FieldFileLike(object):
"""
Given a file-like object, vaguely simulate a Django FieldFile.
@@ -148,15 +145,25 @@ def overlayNewJSON(request):
if not form.is_valid():
return ErrorJSONResponse( form.errors )
else:
-
- # test to see if there is an image file
- # file takes precedence over image url
image = None
imageRef = form.cleaned_data['image']
imageFB = None
imageType = None
imageName = None
- if not imageRef:
+ # test to see if there is an image file
+ if imageRef:
+ # file takes precedence over image url
+ imageFB = imageRef.file
+ imageType = imageRef.content_type
+ imageName = imageRef.name
+ imageSize = imageRef.size
+ # 10% "grace period" on max import file size
+ if imageSize > settings.MAX_IMPORT_FILE_SIZE * 1.1:
+ return ErrorJSONResponse("Your overlay image is %s MB, larger than the maximum allowed size of %s MB."
+ % (toMegaBytes(imageSize),
+ toMegaBytes(settings.MAX_IMPORT_FILE_SIZE)))
+
+ else:
# no image, proceed to check for url
if not form.cleaned_data['imageUrl']:
# what did the user even do
@@ -181,26 +188,23 @@ def overlayNewJSON(request):
imageType = response.headers['Content-Type']
imageName = form.cleaned_data['imageUrl'].split('/')[-1]
response.close()
- else:
- imageFB = imageRef.file
- imageType = imageRef.content_type
- imageName = imageRef.name
- imageSize = imageRef.size
- if imageSize > settings.MAX_IMPORT_FILE_SIZE:
- return ErrorJSONResponse("The submitted file is larger than the maximum allowed size. Maximum size is %d bytes." % settings.MAX_IMPORT_FILE_SIZE)
-
+
imageData = models.ImageData(contentType=imageType)
- if settings.PDF_IMPORT_ENABLED and imageType in PDF_MIME_TYPES:
+ bits = imageFB.read()
+ if imageType in PDF_MIME_TYPES:
+ if not settings.PDF_IMPORT_ENABLED:
+ return ErrorJSONResponse("PDF images are no longer supported.")
+
# convert PDF to raster image
- pngData = pdf.convertPdf(imageFB.read())
+ pngData = pdf.convertPdf(bits)
imageData.image.save('dummy.png', ContentFile(pngData), save=False)
imageData.contentType = 'image/png'
else:
try:
- image = PIL.Image.open(imageFB)
+ image = PIL.Image.open(StringIO(bits))
except Exception as e:
- logging.error( "PIL failed to open image: " + str(e) )
+ logging.error( "PIL failed to open image: " + str(e) )
return ErrorJSONResponse("There was a problem reading the image.")
if image.mode != 'RGBA':
# add alpha channel to image for better
@@ -383,8 +387,8 @@ def overlayIdJson(request, key):
@csrf_exempt
def overlayListJson(request):
# return only the last 100 overlays for now. if it gets longer than that, we'll implement paging.
- overlays = Overlay.objects.order_by('-lastModifiedTime')[:100]
-
+ overlays = Overlay.objects.order_by('-lastModifiedTime')[:100]
+
return HttpResponse(dumps(list(o.jsonDict for o in overlays)), content_type='application/json')
Please sign in to comment.
Something went wrong with that request. Please try again.