코 세라 UCSD 자바 클래스의 일환으로, 우리는 가공 작업 및지도 라이브러리를 펼쳐있다.
이 과정은 내가 확장하려고 스타터 코드를 제공합니다. 하지만 문제 다 퉜다.
내 공부의 대부분을 내 작품을 컴퓨터에, 나는 정말 좋은 응용 프로그램을 시작합니다. 내 홈 노트북 내 github의의의 repo를 복제하여, 그녀를 보여주기 위해 내 아내에게 집에 가져하기로 결정했다.
내가 처리에서 직접 다운로드의 펼쳐 다운로드 페이지 있도록 librar / JAR 파일의 없음은 포함되지 않았다. 결과는 악몽이었다. 오류 후 오류 후 오류가 발생했습니다. 나는 코 세라는 / UCSD이 라이브러리의 이전 버전을 사용하는 가정, 새로운 버전은 이전 버전과 호환되지 않습니다. 엉터리지만, 어떤 보인다.
다음으로는 코 세라 시력의 모든 JAR 파일을 다운로드했습니다. 결과는 조금 더 나은,하지만 상황이 여전히 꽤 이상한 있습니다. 내가 만들 때 즉, UnfoldingMap()
객체를 윈도우 내에서의 위치뿐만 아니라 크기에 대한 매개 변수가 절대적으로 아무것도 할 수 없습니다.
1) 내가 처리 사용 size()
크기 최대 방법 또는 포함 된 창 아래, 그것은지도 객체를 확장 또는 아래로. 그것은 완전히의 크기와 위치 인수를 무시합니다 UnfoldingMap()
.
2)지도 객체는 항상 더 창의 왼쪽 아래 구석에 밀어없는 위치를 그것의 인수를 문제입니다.
3) 회색 background()
내가 선택한이지도를 주변에 보여 않지만, 배경 자체가 다음 큰 검은 필드에 둘러싸여 그와도 규모 size()
매개 변수를 설정합니다.
여기에 몇 가지 코드는 다음과 같습니다
package module3;
//Java utilities libraries
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
//Processing library
import processing.core.PApplet;
//Unfolding libraries
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.marker.Marker;
import de.fhpotsdam.unfolding.data.PointFeature;
import de.fhpotsdam.unfolding.marker.SimplePointMarker;
import de.fhpotsdam.unfolding.providers.Google;
import de.fhpotsdam.unfolding.providers.MBTilesMapProvider;
import de.fhpotsdam.unfolding.utils.MapUtils;
//Parsing library
import parsing.ParseFeed;
public class EarthquakeCityMap extends PApplet {
// Less than this threshold is a light earthquake
public static final float THRESHOLD_MODERATE = 5;
// Less than this threshold is a minor earthquake
public static final float THRESHOLD_LIGHT = 4;
// This is where to find the local tiles, for working without an
// Internet connection
public static String mbTilesString = "blankLight-1-3.mbtiles";
// The map
private UnfoldingMap map;
//feed with magnitude 2.5+ Earthquakes
private String earthquakesURLweek = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.atom";
private String earthquakesURLday = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.atom";
public void setup() {
size(400, 400, "processing.opengl.PGraphics3D");
background(99);
map = new UnfoldingMap(this, 50, 50, 1100, 700, new Google.GoogleMapProvider());
map.zoomToLevel(2);
MapUtils.createDefaultEventDispatcher(this, map);
//List of markers to be added to map
List<Marker> markers = new ArrayList<Marker>();
//Use parser to collect properties for each earthquake
//PointFeatures have a getLocation method
List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this, earthquakesURLweek);
// for each earthqauke feature, create a custom marker and add it
// to the list.
for (PointFeature quake : earthquakes){
Marker quakeMark = createMarker(quake);
markers.add(quakeMark);
Map<String, Object> properties = quakeMark.getProperties();
}
// Add the markers to the map so that they are displayed
map.addMarkers(markers);
}
/**
* A helper method to style markers based on features (magnitude, depth,
* etc) of an earthquake.
* @param feature A PointFeature object representing a single earthquake.
* @return
*/
private SimplePointMarker createMarker(PointFeature feature){
// Create a new SimplePointMarker at the location given by the PointFeature
SimplePointMarker marker = new SimplePointMarker(feature.getLocation(), feature.getProperties());
Object magObj = feature.getProperty("magnitude");
Object ageObj = marker.getProperty("days ellapsed");
float mag = Float.parseFloat(magObj.toString());
int age = (int) ageObj;
//Set processing color and alpha data, for setting marker colors
//below.
int alpha = 255 - (age * 255 / 7);
int yellow = color(255, 255, 0, alpha);
int red = color(255, 0, 0, alpha);
int green = color(0, 255, 0, alpha);
// Style markers based on earthquake magnitude
if (mag < THRESHOLD_LIGHT){
marker.setColor(green);
}
if (mag >= THRESHOLD_LIGHT && mag < THRESHOLD_MODERATE){
marker.setColor(yellow);
}
if (mag >= THRESHOLD_MODERATE){
marker.setColor(red);
}
//set radius of marker based on quake magnitude
float radius = (float) (mag * 3.5);
marker.setStrokeColor(color(50,15));
marker.setRadius(radius);
return marker;
}
public void draw() {
map.draw();
addKey();
}
가장 쉬운 옵션처럼 여전히 지원을 펼쳐 것을 오래된 버전의 처리를 사용하는 것 (처리 2.2.1) 0.9.6을 펼쳐 .
당신은 이클립스를 사용하고 있기 때문에 당신은 실제로 당신을 위해 최신 버전의 힘 작업을 컴파일 할 수 있습니다. (필자는 몇 가지가 알아 차리지없는거야 마이너 업데이트 작년는 있지만 자료). 당신이 할 수있는 일식을 통해 업데이트하려면 :
- (당신이 이미 수도 유닉스 시스템 (리눅스 / OSX)에있어 경우 REPO를 얻을
git
: 설치git clone https://github.com/tillnagel/unfolding
: 항상 최신 업데이트를 가져 쉽게 재 구축 할 수 있습니다 이러한 방법 등을 달리 다운로드 압축, 압축 해제) - 이클립스에서 프로젝트를 가져 오기 (가져 오기 프로젝트를 기존 통해)
- 드래그에 프로젝트의 build.xml 개미보기 및 컴파일 할 대상을 선택합니다.
main
프로세싱 래퍼를 포함하여 그들 모두를 컴파일합니다.
당신은 단지 명령 줄을 사용하려면 :
- 설치 Ant를 (즉, 시스템에 이미 아니라면) 당신에 추가
PATH
환경 변수 (예를 들어 확인하려면echo $PATH
유닉스 나echo %PATH%
윈도우와 개미의 삶을 나와있는 폴더를 보장을 추가하지 않은 경우) - 클론 /를 REPO를 다운로드
- 개미를 실행 (예를 들어
ant unfolding_processing
처리를 구축하기 위해 래퍼 만하거나ant
(이는 기본값main
대상 건물 모두)
나는 3.4 처리와 GitHub의 작품에서 최신 버전을 컴파일 수동으로 확인할 수 있습니다
내가 처리 래퍼를 업로드 한 여기 : 희망은 당신이 당신의 Eclipse 프로젝트의 상단에 .jar 파일을 드래그 할 수 있습니다.