Permalink
Browse files

DrawingMilitaryBases

  • Loading branch information...
1 parent dc83ba1 commit d8ca3941a7d3fe567a151a84253342344ebf1c12 @pjimen5 pjimen5 committed Oct 29, 2011
Showing with 50 additions and 3 deletions.
  1. +16 −1 MapView.pde
  2. +2 −2 SettingsView.pde
  3. +23 −0 Sighting.pde
  4. +9 −0 cs424p3.pde
View
@@ -156,6 +156,8 @@ class MapView extends View {
if (showAirports)
drawAirports(papplet.g, airportsMap.values());
+ if (showMilitaryBases)
+ drawMilitaryBases(papplet.g,militaryBaseMap.values());
drawPlacesInformationBox();
@@ -216,12 +218,25 @@ class MapView extends View {
float pointSize = map(zoomValue, minZoom, maxZoom, minDistSize, maxDistSize);
float iconSize = map(zoomValue,minZoom,maxZoom,minIconSize,maxIconSize);
Point2f p = mmap.locationPoint(airport.loc);
-
buffer.ellipse(p.x,p.y,pointSize,pointSize);
buffer.image(airplaneImage,p.x,p.y,iconSize,iconSize);
}
}
+ void drawMilitaryBases(PGraphics buffer, Iterable<Place> militaryBases){
+ buffer.imageMode(CENTER);
+ buffer.noStroke();
+ buffer.fill(airportAreaColor,40);
+ for (Place militaryBase : militaryBases) {
+ float pointSize = map(zoomValue, minZoom, maxZoom, minDistSize, maxDistSize);
+ float iconSize = map(zoomValue,minZoom,maxZoom,minIconSize,maxIconSize);
+ Point2f p = mmap.locationPoint(militaryBase.loc);
+ println("mb lat,lon " +militaryBase.loc + " x,y " + p.x + " " +p.y);
+ buffer.ellipse(p.x,p.y,pointSize,pointSize);
+ buffer.image(militaryBaseImage,p.x,p.y,iconSize,iconSize);
+ }
+ }
+
void drawPlaces(PGraphics buffer, Iterable<Place> places) {
buffer.imageMode(CENTER);
buffer.strokeWeight(0.8);
View
@@ -47,10 +47,10 @@ class SettingsView extends View {
i++;
}
- showAirport = new Checkbox(800,10,12,12,"Show airports",loadImage("plane.png"));
+ showAirport = new Checkbox(800,10,12,12,"Show airports",airplaneImage);
this.subviews.add(showAirport);
- showMilitaryBases = new Checkbox(800,40,12,12,"Show military bases",loadImage("irkickflash2.png"));
+ showMilitaryBases = new Checkbox(800,30,12,12,"Show military bases",militaryBaseImage);
this.subviews.add(showMilitaryBases);
showView = false;
View
@@ -196,6 +196,29 @@ void loadAirports()
println(stopWatch());
}
+void loadMilitaryBases()
+{
+ stopWatch();
+ print("Loading military bases...");
+ db.query("select * from military_bases");
+ militaryBaseMap = new HashMap<Integer,Place>();
+
+ while (db.next()) {
+ militaryBaseMap.put(db.getInt("id"), new Place(AIRPORT,
+ db.getInt("id"),
+ new Location((db.getFloat("lat")/100), (db.getFloat("lon")/100)),
+ db.getString("name"),
+ 0
+ ));
+ }
+ println(stopWatch());
+ print("Building military bases R-tree...");
+
+ militaryBaseTree = new PRTree<Place> (new PlaceMBRConverter(), 10);
+ militaryBaseTree.load(militaryBaseMap.values());
+ println(stopWatch());
+}
+
Iterable<Place> placesInRect(Location locTopLeft, Location locBottomRight, double expandFactor)
{
double minLon = locTopLeft.lon;
View
@@ -23,6 +23,7 @@ color textColor = 255;
color boldTextColor = #FFFF00;
color viewBackgroundColor = #2D2A36;
color airportAreaColor = #FFA500;
+color militaryBaseColor = #CC0000;
color infoBoxBackground = #000000;
color[] UFOColors = {#000000,#ffffff,#555555,#333333,#444444,#555555,#666666};
@@ -38,16 +39,20 @@ String[] UFOTypeLabels = {"UFOType 1","UFOType 2","UFOType 3","UFOType 4","UFOTy
String[] UFOImages = {"blue.png","green.png","star.png","orange.png","purple.png","red.png","yellow.png"};
PImage airplaneImage;
+PImage militaryBaseImage;
SightingTable sightings;
Map<Integer,Place> placeMap;
Map<Integer,Place> airportsMap;
+Map<Integer,Place> militaryBaseMap;
PRTree<Place> placeTree;
PRTree<Place> airportsTree;
+PRTree<Place> militaryBaseTree;
Map<Integer,SightingType> sightingTypeMap;
Sighting clickedSighting;
Boolean showAirports=false;
+Boolean showMilitaryBases = false;
Boolean btwMonths = false;
Boolean btwTime = false;
String byType = "";
@@ -79,6 +84,7 @@ void setup()
loadSightingTypes();
loadCities();
loadAirports();
+ loadMilitaryBases();
reloadCitySightingCounts();
sightings = new DummySightingTable();
@@ -88,6 +94,7 @@ void setup()
font = loadFont("Helvetica-48.vlw");
airplaneImage = loadImage("plane.png");
+ militaryBaseImage = loadImage("irkickflash2.png");
mapv = new MapView(0,0,width,height);
rootView.subviews.add(mapv);
@@ -135,6 +142,8 @@ void mouseDragged()
void mouseClicked()
{
showAirports = settingsView.showAirport.value;
+ showMilitaryBases = settingsView.showMilitaryBases.value;
+
String tmpByType = "";
for (SightingType st : sightingTypeMap.values()) {
Checkbox cb = settingsView.typeCheckboxMap.get(st);

0 comments on commit d8ca394

Please sign in to comment.