Hotels by star
from 1 star on the far most left to 5 stars on the far most right:
Image may be NSFW.
Clik here to view.
Processing sketch:
BufferedReader myReader; void setup() { size(5000,600); background(0); myReader = createReader("../data/hotelsbase.csv"); try { String ln; int c = 0; colorMode(HSB); while((ln = myReader.readLine()) != null) { //println(ln); String[] cols = ln.split("~"); if(cols.length > 11) { float lat = float(cols[12]); float lon = float(cols[13]); float stars = float(cols[2]); int offset = (int(stars) - 1) * 1000; float x = map(lon,-180,180,0,1000); float y = height - map(lat,-90,90,0,height); x = x + offset; float col = map(stars,0,5,0,220); stroke(col,255,255); point(x,y); } c++; if(c % 1000 == 0) println(c); } saveFrame("/Users/federicozannier/mySchool/ITPSpring2013/DataRep/06_week/stars/stars.jpg"); } catch(Exception e) { println("READER FAILED" + e); } } void draw() { }
Most northern hotel
- ID: 260878
- Name: Svalbard Lodge Longyearbyen
- Stars: 3
- Price: 982
- CityName: Longyearbyen
- CountryName: Norway
- tripadvisorUrl: http://www.svalbard.net/~/Hotel_Review-g503715-d1507557-Reviews-Gjestehuset_102_Guest_House_102-Longyearbyen_Spitsbergen_Svalbard.html
- latitude: 78.2181
- longitude: 15.65
Processing sketch:
BufferedReader myReader; void setup() { myReader = createReader("../data/hotelsbase.csv"); try { String ln; int c = 0; float prevLat = 0; Hotel northernMost = new Hotel(); while((ln = myReader.readLine()) != null) { String[] cols = ln.split("~"); if(cols.length > 11) { float currLat = float(cols[12]); if(currLat > prevLat) { northernMost.setData(ln); } } c++; if(c % 1000 == 0) println(c); } northernMost.print(); } catch(Exception e) { println("READER FAILED" + e); } } void draw() { } lass Hotel{ String data; void setData(String _data) { data = _data; } void print() { println(data); } }
Most isolated hotel
- country: Russia
- name: Talnakh Hotel
- latitude: 69.3304
- longitude: 88.2204
Processing sketch:
BufferedReader myReader; ArrayList <Hotel> hotels = new ArrayList();; void setup() { size(1280,720); background(0); myReader = createReader("../data/hotelsbase.csv"); try { String ln; int c = 0; colorMode(HSB); while((ln = myReader.readLine()) != null) { //println(ln); String[] cols = ln.split("~"); if(cols.length > 11) { float lat = float(cols[12]); float lon = float(cols[13]); String name = cols[1]; String country = cols[7]; if(lat < 90 && lat > -90 && lon < 180 && lon > -180) { hotels.add(new Hotel(name,country, lat, lon)); } // float x = map(lon,-180,180,0,width); // float y = height - map(lat,-90,90,0,height); // float stars = float(cols[2]); // float col = map(stars,0,5,0,220); // stroke(col,255,255); // point(x,y); } c++; if(c % 1000 == 0) println(c); } int indexMostIsolated = 0; float maxDist = 0, minDist = 0; for (int i = hotels.size()-1; i >= 0; i--) { Hotel h = (Hotel)hotels.get(i); minDist = h.distanceFromClosest(hotels,10); if(minDist > maxDist) { maxDist = minDist; indexMostIsolated = i; } if(i % 1000 == 0) println(i); } Hotel mostIsolated = (Hotel)hotels.get(indexMostIsolated); println("name: " + mostIsolated.name + " - where: " + mostIsolated.country + "(" + mostIsolated.lat + ", " + mostIsolated.lon + ")"); } catch(Exception e) { println("READER FAILED" + e); } } void draw() { } class Hotel { String name; String country; float lat; float lon; Hotel(String _name, String _country, float _lat, float _lon) { name = _name; country = _country; lat = _lat; lon = _lon; } float distanceFromClosest(ArrayList<Hotel> _hotels, float threshold) { float minDist = 0; for (int i = hotels.size()-1; i >= 0; i--) { Hotel h = (Hotel)hotels.get(i); float tmp = sqrt(pow((h.lat - lat),2) + pow((h.lon - lon),2)); if(tmp < threshold) { return 0; } minDist = tmp; // if(i % 1000 == 0) // println(i); } return minDist; } }