loyaltyRanges seem to be working; ready for data

This commit is contained in:
Ryan Carpenter
2016-09-05 00:12:30 +08:00
parent 02e161e5c4
commit cfb541a0a2
5 changed files with 146 additions and 49 deletions
+18 -4
View File
@@ -14,7 +14,7 @@ angular.module('quartermaester')
characterPaths: true,
houseHeraldry: false,
geographicRegions: false,
politicalAllegiances: false,
politicalAllegiances: true,
characters: {}
};
$scope.map = {
@@ -49,6 +49,7 @@ angular.module('quartermaester')
$scope.episodes = [];
$scope.chapters = [];
$scope.searchResults = [];
$scope.clickHistory = [];
$scope.toState = toState;
$scope.slideTo = slideTo;
$scope.panTo = panTo;
@@ -97,7 +98,10 @@ angular.module('quartermaester')
path.editable = true;
return path;
});
// console.log("mapModels.paths", foo, $scope.mapModels.paths);
$scope.mapModels.loyaltyRanges = $filter('qmSlider')(qmData.loyaltyRanges, $scope.slider);
console.log("mapModels.loyaltyRanges", $scope.mapModels.loyaltyRanges);
//console.log("mapModels.regions", $scope.mapModels.regions);
}
function panToCharacter(newValue, oldValue) {
@@ -280,9 +284,19 @@ angular.module('quartermaester')
function mapClick(a, b, c, d) {
$scope.state = "slider";
//console.log(a, b, c, d);
// console.log(c[0].latLng.lat());
//console.log("lng", c[0].latLng.lng());
//$scope.lastClick = JSON;
console.log($scope.mapModels.paths);
//console.log($scope.mapModels.paths);
addClickToEditor(c[0].latLng.lat(), c[0].latLng.lng())
}
function addClickToEditor(latitude, longitude) {
$scope.clickHistory.push({
latitude: latitude,
longitude: longitude
});
//console.log("history", $scope.clickHistory);
//$scope.$apply();
}
function onMapLoad(maps) {
+37 -1
View File
@@ -69,17 +69,20 @@ angular.module('quartermaester')
getFile('houses.csv'),
getFile('characters.csv'),
getFile('regions.csv'),
getFile('loyaltyRanges.csv'),
getFile('towns.csv'),
getFile('borders.csv'),
getFile('loyaltyRangeEdges.csv'),
getFile('stops.csv'),
getFile('waypoints.csv'),
getFile('paths.csv')
]).spread(parseData);
}
function parseData(books, chapters, seasons, episodes, houses, characters, regions, towns, borders, stops, waypoints, paths) {
function parseData(books, chapters, seasons, episodes, houses, characters, regions, loyaltyRanges, towns, borders, loyaltyRangeEdges, stops, waypoints, paths) {
var qmData = {
borderArrays: {},
lrEdgeArrays: {},
waypointArrays: {},
bookLookup: {}
};
@@ -91,6 +94,17 @@ angular.module('quartermaester')
qmData.borderArrays[borders[i].name].push(borders[i]);
}
for (var i=0; i<loyaltyRangeEdges.length; i++) {
if (!(loyaltyRangeEdges[i].key in qmData.lrEdgeArrays))
qmData.lrEdgeArrays[loyaltyRangeEdges[i].key] = [];
qmData.lrEdgeArrays[loyaltyRangeEdges[i].key].push(loyaltyRangeEdges[i]);
// qmData.lrEdgeArrays[loyaltyRangeEdges[i].key].push({
// latitude: parseFloat(loyaltyRangeEdges[i].latitude),
// longitude: parseFloat(loyaltyRangeEdges[i].longitude)
// });
}
//console.log("qmData.lrEdgeArrays", qmData.lrEdgeArrays);
for (var i=0; i<waypoints.length; i++) {
if (!(waypoints[i].key in qmData.waypointArrays))
qmData.waypointArrays[waypoints[i].key] = [];
@@ -106,6 +120,7 @@ angular.module('quartermaester')
qmData.books = books;
qmData.regions = regions.map(regionModel);
qmData.characters = characters.map(characterModel);
qmData.loyaltyRanges = loyaltyRanges.map(loyaltyRangeModel);
qmData.towns = getTownMarkers(towns, houses);
qmData.heraldry = houses.map(heraldryMarkerModel);
qmData.characterMarkers = stops.map(characterMarkerModel);
@@ -321,6 +336,27 @@ angular.module('quartermaester')
};
}
function loyaltyRangeModel(loyaltyRange) {
var matchingCharacter = {color: "#eeeeee"};
console.log(loyaltyRange);
var keyMatch = /(.+)\-\d+$/.exec(loyaltyRange.key);
if (keyMatch[1]!="Undeclared") matchingCharacter = $filter('filter')(qmData.characters, {key: keyMatch[1]})[0];
return {
key: loyaltyRange.key,
fill: {
color: matchingCharacter.color,
opacity: 0.5
},
stroke: {weight: 0},
path: qmData.lrEdgeArrays[loyaltyRange.key],
timing: {
episodes: [getEpisodeId(loyaltyRange.firstEpisode), getEpisodeId(loyaltyRange.lastEpisode)],
chapters: [getChapterId(loyaltyRange.firstChapter), getChapterId(loyaltyRange.lastChapter)]
}
};
}
function characterMarkerModel(stop, index, fullArray) {
var matchingCharacter = $filter('filter')(qmData.characters, {key: stop.character})[0];
var coords = (stop.town=="") ? {latitude:parseFloat(stop.latitude), longitude:parseFloat(stop.longitude)} : $filter('filter')(qmData.towns, {key: stop.town})[0].coords;