Skip to content

Commit e6d8986

Browse files
Ty CoghlanTy Coghlan
Ty Coghlan
authored and
Ty Coghlan
committed
Initial commit
0 parents  commit e6d8986

28 files changed

+545
-0
lines changed

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Unfolding - Map Library
2+
3+
Copyright (C) 2013 Till Nagel, and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

buildingDB.csv

+47
Large diffs are not rendered by default.

lib/VisualizationIntelliJProjects.jar

10.4 KB
Binary file not shown.

lib/core.jar

619 KB
Binary file not shown.
3.96 KB
Binary file not shown.
2.75 KB
Binary file not shown.

lib/gluegen-rt-natives-linux-i586.jar

3.99 KB
Binary file not shown.
4.77 KB
Binary file not shown.
7.75 KB
Binary file not shown.
7.19 KB
Binary file not shown.

lib/gluegen-rt.jar

282 KB
Binary file not shown.

lib/jogl-all-natives-linux-amd64.jar

197 KB
Binary file not shown.
140 KB
Binary file not shown.

lib/jogl-all-natives-linux-i586.jar

196 KB
Binary file not shown.
397 KB
Binary file not shown.
212 KB
Binary file not shown.

lib/jogl-all-natives-windows-i586.jar

183 KB
Binary file not shown.

lib/jogl-all.jar

2.94 MB
Binary file not shown.

lib/json4processing.jar

30 KB
Binary file not shown.

lib/libTUIO.jar

22.7 KB
Binary file not shown.

lib/log4j-1.2.15.jar

383 KB
Binary file not shown.

lib/sqlite-jdbc-3.7.2.jar

3.05 MB
Binary file not shown.

lib/unfolding.0.9.6.jar

158 KB
Binary file not shown.

measureDB_parallel.csv

+1
Large diffs are not rendered by default.

read.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Manifest-Version: 1.0
2+
Class-Path: groovy-all-2.3.9.jar core.jar gluegen-rt.jar jogl-all.jar
3+
json4processing.jar libTUIO.jar log4j-1.2.15.jar sqlite-jdbc-3.7.2.ja
4+
r unfolding.0.9.6.jar VisualizationIntelliJProjects.jar
5+
Main-Class: VisualizationMap.HelloUnfoldingWorld
6+

siteDB.csv

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
sID,Name,Abbreviation,bID
2+
0,Barletta Natatorium,BN,0
3+
1,Behrakis Center,BK,1
4+
2,Cabot Center,CB,2
5+
3,Cargill Hall,CG,3
6+
4,Churchill Hall,CH,4
7+
5,Columbus Place,CP,5
8+
6,Cullinane Hall,CN,6
9+
7,Curry Student Center,CSC,7
10+
8,Dana Research Center,DA,8
11+
9,Dockser Hall,DK,9
12+
10,Dodge Hall,DG,10
13+
11,Egan Research Center,EC,11
14+
12,Ell Hall,EL,12
15+
13,Fenway Center,FC,13
16+
14,Forsyth Visual.Building,FR,14
17+
15,Hayden Hall,HA,15
18+
16,Holmes/Meserve,HO/ME,16
19+
17,Hurtig Hall,HT,17
20+
18,International Village,INV,18
21+
19,Kariotis Hall,KA,19
22+
20,Knowles Center,KN,20
23+
21,Lake/Nightingale,LA/NI,21
24+
22,Levine Hall,LV,22
25+
23,Marino Recreation Center,MC,23
26+
24,Marino Vendor - ABP, MV-ABP,23
27+
25,Marino Vendor - NO, MV-NO,23
28+
26,Marino Vendor - SPTA, MV-SPTA,23
29+
27,Marino Vendor - Wollastons, MV-WO,23
30+
28,Marino Vendor - Wraps, MV-WR,23
31+
29,Matthews Arena,MA,24
32+
30,Mugar Visual.Building,MU,25
33+
31,Power Plant,PP,26
34+
32,Richards Hall,RI,27
35+
33,Robinson Hall,RB,28
36+
34,Ryder Hall,RY,29
37+
35,Shillman Hall,SH,30
38+
36,Snell Engineering Center,SN,31
39+
37,Snell Library,SL,32
40+
38,Speare Hall,SP,33
41+
39,Stearns Center,ST,34
42+
40,Stetson West,SW,35
43+
41,Stetson East,SE,36
44+
42,West Village A,WVA,37
45+
43,West Village B,WVB,38
46+
44,West Village B Vendor - Wollastons,WVBV-WO,38
47+
45,West Village C,WVC,39
48+
46,West Village E,WVE,40
49+
47,West Village F,WVF,41
50+
48,West Village G,WVG,42
51+
49,West Village H,WVH,43
52+
50,White Hall,WH,44
53+
51,Willis Hall,WI,45
+244
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
package VisualizationMap;
2+
3+
import de.fhpotsdam.unfolding.geo.Location;
4+
import de.fhpotsdam.unfolding.marker.SimplePolygonMarker;
5+
import de.fhpotsdam.unfolding.utils.MapPosition;
6+
7+
import java.text.DateFormat;
8+
import java.text.ParseException;
9+
import java.text.SimpleDateFormat;
10+
import java.util.ArrayList;
11+
import java.util.Collections;
12+
import java.util.Date;
13+
import java.util.List;
14+
import java.util.Objects;
15+
16+
17+
import Visual.Building;
18+
import Visual.LatLong;
19+
import processing.core.PGraphics;
20+
21+
/**
22+
* A marker used to represent a building on the map
23+
*/
24+
public final class BuildingMarker extends SimplePolygonMarker implements Comparable<BuildingMarker> {
25+
Building building;
26+
private Color c;
27+
BuildingMarker(Building b/*, Color c*/) {
28+
Objects.requireNonNull(b, "Building must be set");
29+
building = b;
30+
List<Location> locations = new ArrayList<>();
31+
for (LatLong l : b.outline()) {
32+
Location loc = new Location(l.longitude(), l.lat());
33+
locations.add(loc);
34+
}
35+
this.addLocations(locations);
36+
c = new Color(255, 255, 255, 0);
37+
}
38+
39+
@Override
40+
public int compareTo(BuildingMarker other) {
41+
Objects.requireNonNull(other);
42+
return this.building.compareTo(other.building);
43+
}
44+
45+
public void draw(PGraphics pg, List<MapPosition> mapPositions) {
46+
// marker
47+
pg.pushStyle();
48+
pg.strokeWeight(2);
49+
pg.stroke(0, 0, 0);
50+
pg.fill(c.r, c.g, c.b, c.alpha);
51+
if (this.isSelected()) {
52+
pg.fill(255, 255, 255, 255);
53+
}
54+
pg.beginShape();
55+
for (MapPosition mapPosition : mapPositions) {
56+
pg.vertex(mapPosition.x, mapPosition.y);
57+
}
58+
pg.endShape();
59+
pg.popStyle();
60+
}
61+
62+
/**
63+
* Sets the fill color
64+
* @param c the new fill color
65+
*/
66+
public void newColor(Color c) {
67+
this.c = c;
68+
}
69+
70+
/**
71+
* Balances out all of the colors according to the current time, from min to max.
72+
*
73+
* @param markers the list of markers to balance out
74+
* @param time the time to balance with
75+
* @throws IllegalArgumentException if there are more than 255 markers
76+
*/
77+
static void balanceColors(ArrayList<BuildingMarker> markers, long time) {
78+
if (markers.size() > 255) {
79+
throw new IllegalArgumentException("Too many markers, can only balance a total" +
80+
"of 255 markers");
81+
}
82+
for (BuildingMarker marker : markers) {
83+
marker.building.changeTime(time);
84+
}
85+
Collections.sort(markers);
86+
for (int i = 0; i < markers.size(); i++) {
87+
BuildingMarker bm = markers.get(i);
88+
if (bm.building.currentWattage() == 0) {
89+
bm.newColor(new Color(0, 128, 255, 225));
90+
} else {
91+
int diff = 255 / markers.size();
92+
bm.newColor(new Color(255, 255 - (diff * i), 0, 175));
93+
}
94+
}
95+
}
96+
97+
/**
98+
* Creates an array of doubles for last specified number of readings differing among the
99+
* specified number of times.
100+
* @param minTime the minimum point which there are no times past
101+
* @param timeDiff how much to offset the times by
102+
* @param numberOfReadings how many times to count down
103+
* @return the array of watts for the last specified times.
104+
*/
105+
double[] lastReadings(long minTime, long timeDiff, int numberOfReadings) {
106+
if (numberOfReadings < 1) {
107+
throw new IllegalArgumentException("There must be a number of readings");
108+
}
109+
if (timeDiff < 1) {
110+
throw new IllegalArgumentException("Must have a positive integer for time difference");
111+
}
112+
double[] result = new double[numberOfReadings];
113+
for (int i = 0; i < numberOfReadings; i++) {
114+
long time = building.currentTime() - (timeDiff * i);
115+
if (time < minTime) {
116+
result[i] = -1.0;
117+
} else {
118+
result[i] = building.wattage(time);
119+
}
120+
}
121+
return result;
122+
}
123+
124+
/**
125+
* Identifies the maximum and minimum value in the array, and scales them down
126+
* to [0, 1]
127+
* @param toScale the array of doubles to scale
128+
* @return an array of values between [0, 1] representing the relative size to the max
129+
* and min value of the original array
130+
*/
131+
double[] scaleDoubles(double[] toScale) {
132+
double max = 0.0;
133+
double min = 0.0;
134+
if (toScale.length > 0) {
135+
max = toScale[0];
136+
min = toScale[0];
137+
}
138+
for (double d : toScale) {
139+
if (d > max) {
140+
max = d;
141+
}
142+
if (d < min) {
143+
min = d;
144+
}
145+
}
146+
max -= min;
147+
double[] result = new double[toScale.length];
148+
if (max == 0) {
149+
return result;
150+
}
151+
for (int i = 0; i < toScale.length; i++) {
152+
result[i] = (toScale[i] - min) / max;
153+
}
154+
return result;
155+
}
156+
157+
/**
158+
* Creates the string array containing the last week worth of power readings
159+
* @param minTime the minimum time that there are no readings past.
160+
* @return the week's worth of readings in a string array.
161+
*/
162+
String[] lastWeek(long minTime) {
163+
String[] result = new String[7];
164+
long currentTime = this.building.currentTime();
165+
long timeDiff = 86400;
166+
SimpleDateFormat sdf = new SimpleDateFormat("MMMM d");
167+
for (int i = 0; i < 7; i++) {
168+
if (i == 0) {
169+
String watt = Double.toString(building.currentWattage());
170+
if (watt.length() > 9) {
171+
watt = watt.substring(0, 9);
172+
}
173+
watt += " Watts";
174+
result[i] = "Today: " + watt;
175+
} else if ((currentTime - (timeDiff * i)) < minTime) {
176+
result[i] = "No such time: ";
177+
} else {
178+
String watt = Double.toString(building.wattage(currentTime - (timeDiff * i)));
179+
if (watt.length() > 9) {
180+
watt = watt.substring(0, 9);
181+
}
182+
watt += " Watts";
183+
result[i] = sdf.format((currentTime - (timeDiff * i)) * 1000) + ": " + watt;
184+
}
185+
}
186+
return result;
187+
}
188+
189+
/**
190+
* Converts the given string date into unix time.
191+
* @param givenDate the string to parse. Must be in "mmddyyyy"
192+
* @return the unix time
193+
*/
194+
static long stringToUnix(String givenDate) {
195+
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
196+
try {
197+
Date date = dateFormat.parse(givenDate);
198+
long unixTime = date.getTime() / 1000;
199+
System.out.println(unixTime);
200+
return unixTime;
201+
} catch (ParseException e) {
202+
throw new IllegalArgumentException("String must be formatted as \"DAYMONTHYEAR in" +
203+
" numbers\"");
204+
}
205+
}
206+
207+
static String unixTostring(long unix) {
208+
DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy 'at' hh:mm");
209+
return dateFormat.format(unix * 1000);
210+
}
211+
212+
/**
213+
* Clamps the given int between [0, 255]
214+
* @param i the number to clamp
215+
* @return the clamped number
216+
*/
217+
private static int clamp(int i) {
218+
if (i > 255) {
219+
return 255;
220+
} else if (i < 0) {
221+
return 0;
222+
} else {
223+
return i;
224+
}
225+
}
226+
227+
228+
/**
229+
* A class to hold rgb values.
230+
*/
231+
static class Color {
232+
public final int r;
233+
public final int g;
234+
public final int b;
235+
public final int alpha;
236+
237+
Color(int r, int g, int b, int alpha) {
238+
this.r = clamp(r);
239+
this.g = clamp(g);
240+
this.b = clamp(b);
241+
this.alpha = clamp(alpha);
242+
}
243+
}
244+
}

0 commit comments

Comments
 (0)