Mercurial > hg > LGMap
comparison geotemco/js/Map/MapDataSource.js @ 0:57bde4830927
first commit
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Tue, 24 Mar 2015 11:37:17 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:57bde4830927 |
|---|---|
| 1 /* | |
| 2 * MapDataSource.js | |
| 3 * | |
| 4 * Copyright (c) 2012, Stefan Jänicke. All rights reserved. | |
| 5 * | |
| 6 * This library is free software; you can redistribute it and/or | |
| 7 * modify it under the terms of the GNU Lesser General Public | |
| 8 * License as published by the Free Software Foundation; either | |
| 9 * version 3 of the License, or (at your option) any later version. | |
| 10 * | |
| 11 * This library is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 * Lesser General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU Lesser General Public | |
| 17 * License along with this library; if not, write to the Free Software | |
| 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
| 19 * MA 02110-1301 USA | |
| 20 */ | |
| 21 | |
| 22 /** | |
| 23 * @class MapDataSource | |
| 24 * implementation for aggregation of map items | |
| 25 * @author Stefan Jänicke (stjaenicke@informatik.uni-leipzig.de) | |
| 26 * @release 1.0 | |
| 27 * @release date: 2012-07-27 | |
| 28 * @version date: 2012-07-27 | |
| 29 * | |
| 30 * @param {MapWidget} parent Widget | |
| 31 * @param {JSON} options map configuration | |
| 32 */ | |
| 33 function MapDataSource(parent, options) { | |
| 34 | |
| 35 this.parent = parent; | |
| 36 this.olMap = parent.openlayersMap; | |
| 37 this.circleSets = []; | |
| 38 this.binning = new Binning(this.olMap, options); | |
| 39 | |
| 40 }; | |
| 41 | |
| 42 MapDataSource.prototype = { | |
| 43 | |
| 44 /** | |
| 45 * initializes the MapDataSource | |
| 46 * @param {MapObject[][]} mapObjects an array of map objects of different sets | |
| 47 */ | |
| 48 initialize : function(mapObjects) { | |
| 49 | |
| 50 if (mapObjects != this.mapObjects) { | |
| 51 this.binning.reset(); | |
| 52 this.binning.setObjects(mapObjects); | |
| 53 } | |
| 54 this.mapObjects = mapObjects; | |
| 55 | |
| 56 var set = this.binning.getSet(); | |
| 57 this.circleSets = set.circleSets; | |
| 58 this.binSets = set.binSets; | |
| 59 this.hashMapping = set.hashMaps; | |
| 60 | |
| 61 }, | |
| 62 | |
| 63 getObjectsByZoom : function() { | |
| 64 var zoom = Math.floor(this.parent.getZoom()); | |
| 65 if (this.circleSets.length < zoom) { | |
| 66 return null; | |
| 67 } | |
| 68 return this.circleSets[zoom]; | |
| 69 }, | |
| 70 | |
| 71 getAllObjects : function() { | |
| 72 if (this.circleSets.length == 0) { | |
| 73 return null; | |
| 74 } | |
| 75 return this.circleSets; | |
| 76 }, | |
| 77 | |
| 78 getAllBins : function() { | |
| 79 if (this.binSets.length == 0) { | |
| 80 return null; | |
| 81 } | |
| 82 return this.binSets; | |
| 83 }, | |
| 84 | |
| 85 clearOverlay : function() { | |
| 86 var zoom = Math.floor(this.parent.getZoom()); | |
| 87 var circles = this.circleSets[zoom]; | |
| 88 for (var i in circles ) { | |
| 89 for (var j in circles[i] ) { | |
| 90 circles[i][j].reset(); | |
| 91 } | |
| 92 } | |
| 93 }, | |
| 94 | |
| 95 setOverlay : function(mapObjects) { | |
| 96 var zoom = Math.floor(this.parent.getZoom()); | |
| 97 for (var j in mapObjects ) { | |
| 98 for (var k in mapObjects[j] ) { | |
| 99 var o = mapObjects[j][k]; | |
| 100 if (o.isGeospatial) { | |
| 101 this.hashMapping[zoom][j][o.index].overlayElements.push(o); | |
| 102 this.hashMapping[zoom][j][o.index].overlay += o.weight; | |
| 103 } | |
| 104 } | |
| 105 } | |
| 106 }, | |
| 107 | |
| 108 size : function() { | |
| 109 if (this.circleSets.length == 0) { | |
| 110 return 0; | |
| 111 } | |
| 112 return this.circleSets[0].length; | |
| 113 }, | |
| 114 | |
| 115 getCircle : function(index, id) { | |
| 116 var zoom = Math.floor(this.parent.getZoom()); | |
| 117 return this.hashMapping[zoom][index][id]; | |
| 118 } | |
| 119 }; |
