diff --git a/.gitignore b/.gitignore index afed073..44fae40 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.csv +*.csv.gz diff --git a/README.md b/README.md index 237b226..0e89e9e 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# cellMapVisualizer \ No newline at end of file +# cellMapVisualizer + + + +![carsincommon](https://raw.githubusercontent.com/arnaucode/cellMapVisualizer/master/cellMapVisualizer01.png "cellMapVisualizer") diff --git a/cellMapVisualizer01.png b/cellMapVisualizer01.png new file mode 100644 index 0000000..981d415 Binary files /dev/null and b/cellMapVisualizer01.png differ diff --git a/main.go b/main.go index 64b976f..4e9affe 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ func main() { if len(os.Args) > 1 { if os.Args[1] == "-dataset" { color.Blue("starting to read dataset") - readDataset("dataModel_head.csv") + readDataset("cell_towers.csv") color.Blue("finished reading dataset") } } diff --git a/mongoModels.go b/mongoModels.go index e0b9030..e40dd6c 100644 --- a/mongoModels.go +++ b/mongoModels.go @@ -7,8 +7,8 @@ type CellModel struct { Area int `json:"area"` Cell int `json:"cell"` Unit int `json:"unit"` - Lon float64 `json:"lon"` Lat float64 `json:"lat"` + Lon float64 `json:"lon"` Range float64 `json:"range"` Samples int `json:"samples"` Changeable string `json:"changeable"` diff --git a/readDataset.go b/readDataset.go index f93d25c..8289651 100644 --- a/readDataset.go +++ b/readDataset.go @@ -2,12 +2,15 @@ package main import ( "bufio" + "fmt" "os" "strconv" "strings" + "time" ) func readDataset(path string) { + tStart := time.Now() inFile, _ := os.Open(path) defer inFile.Close() scanner := bufio.NewScanner(inFile) @@ -39,4 +42,8 @@ func readDataset(path string) { } lineNum++ } + fmt.Print("line num: ") + fmt.Println(lineNum) + fmt.Print("time elapsed from start: ") + fmt.Println(time.Since(tStart)) } diff --git a/serverRoutes.go b/serverRoutes.go index 39aadd6..df586e6 100644 --- a/serverRoutes.go +++ b/serverRoutes.go @@ -4,6 +4,9 @@ import ( "encoding/json" "fmt" "net/http" + "strconv" + + "github.com/gorilla/mux" "gopkg.in/mgo.v2/bson" ) @@ -23,6 +26,12 @@ var routes = Routes{ "/allcells", GetAllCells, }, + Route{ + "GetCellsInQuad", + "Get", + "/cells/{lat1}/{lon1}/{lat2}/{lon2}", + GetCellsInQuad, + }, } //ROUTES @@ -44,3 +53,27 @@ func GetAllCells(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, string(jsonCells)) } +func GetCellsInQuad(w http.ResponseWriter, r *http.Request) { + ipFilter(w, r) + + vars := mux.Vars(r) + lat1, err := strconv.ParseFloat(vars["lat1"], 64) + check(err) + lon1, err := strconv.ParseFloat(vars["lon1"], 64) + check(err) + lat2, err := strconv.ParseFloat(vars["lat2"], 64) + check(err) + lon2, err := strconv.ParseFloat(vars["lon2"], 64) + check(err) + fmt.Println(vars) + + cells := []CellModel{} + iter := cellCollection.Find(bson.M{"lat": bson.M{"$gte": lat2, "$lt": lat1}, "lon": bson.M{"$gte": lon1, "$lt": lon2}}).Limit(100).Iter() + err = iter.All(&cells) + + //convert []cells struct to json + jsonCells, err := json.Marshal(cells) + check(err) + + fmt.Fprintln(w, string(jsonCells)) +} diff --git a/web/css/colors.css b/web/css/colors.css index f7f8872..84755ec 100644 --- a/web/css/colors.css +++ b/web/css/colors.css @@ -1,16 +1,3 @@ -/* red */ -.c_red50{ - background: #FFEBEE!important; - color: #000000!important; -} -.c_red100{ - background: #FFCDD2!important; - color: #000000!important; -} -.c_red200{ - background: #EF9A9A!important; - color: #000000!important; -} .c_red300{ background: #E57373!important; color: #ffffff!important; @@ -23,117 +10,6 @@ background: #F44336!important; color: #ffffff!important; } -.c_red600{ - background: #E53935!important; - color: #ffffff!important; -} -.c_red700{ - background: #D32F2F!important; - color: #ffffff!important; -} -.c_red800{ - background: #C62828!important; - color: #ffffff!important; -} -.c_red900{ - background: #B71C1C!important; - color: #ffffff!important; -} - -.ctext_red400{ - color: #EF5350!important; -} -.ctext_red500{ - color: #F44336!important; -} -.ctext_red600{ - color: #E53935!important; -} - -/* pink */ -.c_pink50{ - background: #FCE4EC!important; - color: #000000!important; -} -.c_pink100{ - background: #F8BBD0!important; - color: #000000!important; -} -.c_pink200{ - background: #F48FB1!important; - color: #000000!important; -} -.c_pink300{ - background: #F06292!important; - color: #ffffff!important; -} -.c_pink400{ - background: #EC407A!important; - color: #ffffff!important; -} -.c_pink500{ - background: #E91E63!important; - color: #ffffff!important; -} -.c_pink600{ - background: #D81B60!important; - color: #ffffff!important; -} -.c_pink700{ - background: #C2185B!important; - color: #ffffff!important; -} -.c_pink800{ - background: #AD1457!important; - color: #ffffff!important; -} -.c_pink900{ - background: #880E4F!important; - color: #ffffff!important; -} - -/* deepPurple */ -.c_deepPurple50{ - background: #EDE7F6!important; - color: #000000!important; -} -.c_deepPurple100{ - background: #D1C4E9!important; - color: #000000!important; -} -.c_deepPurple200{ - background: #B39DDB!important; - color: #000000!important; -} -.c_deepPurple300{ - background: #9575CD!important; - color: #ffffff!important; -} -.c_deepPurple400{ - background: #7E57C2!important; - color: #ffffff!important; -} -.c_deepPurple500{ - background: #673AB7!important; - color: #ffffff!important; -} -.c_deepPurple600{ - background: #5E35B1!important; - color: #ffffff!important; -} -.c_deepPurple700{ - background: #512DA8!important; - color: #ffffff!important; -} -.c_deepPurple800{ - background: #4527A0!important; - color: #ffffff!important; -} -.c_deepPurple900{ - background: #311B92!important; - color: #ffffff!important; -} - /* indigo */ .c_indigo50{ background:#E8EAF6!important; @@ -265,19 +141,6 @@ color: #ffffff!important; } -/* green */ -.c_green50{ - background: #E8F5E9!important; - color: #000000!important; -} -.c_green100{ - background: #C8E6C9!important; - color: #000000!important; -} -.c_green200{ - background: #A5D6A7!important; - color: #000000!important; -} .c_green300{ background: #81C784!important; color: #ffffff!important; @@ -290,107 +153,6 @@ background: #4CAF50!important; color: #ffffff!important; } -.c_green600{ - background: #43A047!important; - color: #ffffff!important; -} -.c_green700{ - background: #388E3C!important; - color: #ffffff!important; -} -.c_green800{ - background: #2E7D32!important; - color: #ffffff!important; -} -.c_green900{ - background: #1B5E20!important; - color: #ffffff!important; -} - -/* yellow */ -.c_yellow50{ - background: #FFFDE7!important; - color: #000000!important; -} -.c_yellow100{ - background: #FFF9C4!important; - color: #000000!important; -} -.c_yellow200{ - background: #FFF59D!important; - color: #000000!important; -} -.c_yellow300{ - background: #FFF176!important; - color: #ffffff!important; -} -.c_yellow400{ - background: #FFEE58!important; - color: #ffffff!important; -} -.c_yellow500{ - background: #FFEB3B!important; - color: #ffffff!important; -} -.c_yellow600{ - background: #FDD835!important; - color: #ffffff!important; -} -.c_yellow700{ - background: #FBC02D!important; - color: #ffffff!important; -} -.c_yellow800{ - background: #F9A825!important; - color: #ffffff!important; -} -.c_yellow900{ - background: #F57F17!important; - color: #ffffff!important; -} - -/* orange */ -.c_orange50{ - background: #FFF3E0!important; - color: #000000!important; -} -.c_orange100{ - background: #FFE0B2!important; - color: #000000!important; -} -.c_orange200{ - background: #FFCC80!important; - color: #000000!important; -} -.c_orange300{ - background: #FFB74D!important; - color: #ffffff!important; -} -.c_orange400{ - background: #FFA726!important; - color: #ffffff!important; -} -.c_orange500{ - background: #FF9800!important; - color: #ffffff!important; -} -.c_orange600{ - background: #FB8C00!important; - color: #ffffff!important; -} -.c_orange700{ - background: #F57C00!important; - color: #ffffff!important; -} -.c_orange800{ - background: #EF6C00!important; - color: #ffffff!important; -} -.c_orange900{ - background: #E65100!important; - color: #ffffff!important; -} - /* grey */ .c_grey50{ background: #FAFAFA!important; diff --git a/web/img/antenna.png b/web/img/antenna.png new file mode 100644 index 0000000..dd1697c Binary files /dev/null and b/web/img/antenna.png differ diff --git a/web/img/antenna2.png b/web/img/antenna2.png new file mode 100644 index 0000000..14ac4ab Binary files /dev/null and b/web/img/antenna2.png differ diff --git a/web/img/antenna3.png b/web/img/antenna3.png new file mode 100644 index 0000000..c1f5b90 Binary files /dev/null and b/web/img/antenna3.png differ diff --git a/web/views/main/main.js b/web/views/main/main.js index e180c59..bfca074 100644 --- a/web/views/main/main.js +++ b/web/views/main/main.js @@ -16,13 +16,21 @@ angular.module('app.main', ['ngRoute', 'ui-leaflet']) $scope.markers = []; $scope.paths = []; $scope.tiles = { - url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + //url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + url: "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png", + // més estils https://leaflet-extras.github.io/leaflet-providers/preview/ options: { attribution: 'OpenStreetMap contributors' } }; + //var antennaIcon = L.icon({ + var antennaIcon = { + iconUrl: 'img/antenna.png', + iconSize: [50, 50], // size of the icon + iconAnchor: [25, 50], // point of the icon which will correspond to marker's location + }; - $http.get(urlapi + 'allcells') + $http.get(urlapi + 'cells/43.73429/7.41841/43.73210/7.42196') .then(function(data) { console.log('data success'); console.log(data); @@ -33,19 +41,15 @@ angular.module('app.main', ['ngRoute', 'ui-leaflet']) $scope.markers.push({ lat: Number($scope.cells[i].lat), lng: Number($scope.cells[i].lon), - message: $scope.cells[i].mcc - }); - $scope.markers.push({ - lat: Number($scope.cells[i].lat), - lng: Number($scope.cells[i].lon), - message: $scope.cells[i].mcc + message: $scope.cells[i].mcc, + icon: antennaIcon }); } $scope.center = { lat: (Number($scope.cells[0].lat) + Number($scope.cells[0].lat)) / 2, lng: (Number($scope.cells[0].lon) + Number($scope.cells[0].lon)) / 2, - zoom: 4 + zoom: 16 }; }, function(data) { console.log('data error');