diff --git a/.classpath b/.classpath
index 28b13bdd..32adc45e 100644
--- a/.classpath
+++ b/.classpath
@@ -1,9 +1,9 @@
-
+
-
+
diff --git a/GO_Sync/pom.xml b/GO_Sync/pom.xml
index 6c1b8aaa..fec5fa63 100644
--- a/GO_Sync/pom.xml
+++ b/GO_Sync/pom.xml
@@ -5,7 +5,7 @@
edu.usf.cutr.osm
gtfs-osm-sync
jar
- 1.0-SNAPSHOT
+ 1.0.1-SNAPSHOT
GO_Sync
https://github.com/CUTR-at-USF/gtfs-osm-sync/
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/MainForm.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/MainForm.java
index 7be5c014..c0d49161 100644
--- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/MainForm.java
+++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/MainForm.java
@@ -90,7 +90,12 @@ public MainForm() {
setMinimumSize(new Dimension(660, 460));
DefaultOperatorReader reader = new DefaultOperatorReader(); //create a new reader
- ops = reader.readOperators(new File("operators.csv").getAbsolutePath()); //read a file with operator info for autocompletion
+ try {
+ ops = reader.readOperators(getClass().getResourceAsStream("/operators.csv")); //read a file with operator info for autocompletion
+ }
+ catch (Exception e) {
+ ops = reader.readOperators(new File("operators.csv").getAbsolutePath()); //read a file with operator info for autocompletion
+ }
//TODO Fix textfield with ops is null (operators.csv doesn't exist)
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/ReportViewer.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/ReportViewer.java
index ae623c93..e4aa8ad4 100644
--- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/ReportViewer.java
+++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/ReportViewer.java
@@ -32,6 +32,7 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
@@ -70,6 +71,7 @@
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.GroupLayout.Alignment;
+import javax.swing.ImageIcon;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
@@ -149,12 +151,32 @@ public class ReportViewer extends javax.swing.JFrame implements TableModelListen
private JProgressBar progressBar;
private boolean generateStopsToUploadFlag = false;
+
+ protected ImageIcon busIcon;
+
+ protected static Color matchColor, selectedOSMColor, selectedGTFSColor;
+
/** Creates new form ReportViewer */
+
+
+
+
public ReportViewer(List aData, Hashtable> r, HashSetu, HashSetm, HashSetd, Hashtable routes, Hashtable nRoutes, Hashtable eRoutes, JTextArea to) {
super("GO-Sync: Report");
super.setResizable(true); //false);
+ try {
+ busIcon = new javax.swing.ImageIcon(this.getClass().getClassLoader().getResource("bus_icon.png"));
+ }
+ catch (Exception e) {
+ busIcon = new javax.swing.ImageIcon(this.getClass().getResource("bus_icon.png"));
+ }
+
+ matchColor = new Color(255,255,0,150);
+ selectedOSMColor = new Color(0,127,0,150);
+ selectedGTFSColor = new Color(0,0,127,150);
+
// set tooltip time for 10 seconds
javax.swing.ToolTipManager.sharedInstance().setDismissDelay(10000);
@@ -631,27 +653,20 @@ private void addNewBusStopToMap(ArrayList newStops){
//crate a WaypointPainter to draw the points
stopsPainter.setWaypoints(waypoints);
- stopsPainter.setRenderer(new DefaultWaypointRenderer() {
- public boolean paintWaypoint(Graphics2D g, JXMapViewer map, JXMapViewer v, Waypoint wp) {
- Image busIcon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/edu/usf/cutr/go_sync/gui/bus_icon.png")); //Toolkit.getDefaultToolkit().getImage("bus_icon.png");
- g.drawImage(busIcon, -5, -5, map);
- return true;
- }
+ stopsPainter.setRenderer(new WaypointRenderer() {
+// public boolean paintWaypoint(Graphics2D g, JXMapViewer map, JXMapViewer v, Waypoint wp) {
+// g.drawImage(busIcon.getImage(), -5, -5, map);
+// return true;
+// }
public void paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint wp) {
- Image busIcon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/edu/usf/cutr/go_sync/gui/bus_icon.png")); //Toolkit.getDefaultToolkit().getImage("bus_icon.png");
Point2D point = map.getTileFactory().geoToPixel(wp.getPosition(), map.getZoom());
int x = (int)point.getX() -16/ 2;
int y = (int)point.getY() -16;
- g.drawImage(busIcon,x, y, map);
- return;
+ g.drawImage(busIcon.getImage(),x, y, map);
+ return ;
}
-// public void paintWaypoint(Graphics2D g, JXMapViewer map,Object waypoint) {
-// Image busIcon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/edu/usf/cutr/go_sync/gui/bus_icon.png")); //Toolkit.getDefaultToolkit().getImage("bus_icon.png");
-// g.drawImage(busIcon, -5, -5, map);
-// System.out.println(busIcon.g);
-// }
});
mainMap.setZoom(1);
@@ -734,7 +749,7 @@ public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
JXMapViewer mainMap = mapJXMapKit.getMainMap();
Iterator it = matchStop.iterator();
while(it.hasNext()){
- g.setColor(new Color(255,255,0,150));
+ g.setColor(matchColor);
Stop st = (Stop)it.next();
GeoPosition st_gp = new GeoPosition(Double.parseDouble(st.getLat()), Double.parseDouble(st.getLon()));
//convert to pixel
@@ -772,7 +787,7 @@ public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
Rectangle rect = map.getViewportBounds();
// g.translate(-rect.x, -rect.y);
- g.setColor(new Color(0,0,127,150));
+ g.setColor(selectedGTFSColor);
JXMapViewer mainMap = mapJXMapKit.getMainMap();
@@ -802,7 +817,7 @@ public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
Rectangle rect = map.getViewportBounds();
// g.translate(-rect.x, -rect.y);
- g.setColor(new Color(0,127,0,150));
+ g.setColor(selectedOSMColor);
JXMapViewer mainMap = mapJXMapKit.getMainMap();
@@ -1142,6 +1157,25 @@ public String GetGeneralInformationToRouteTextArea(){
public void SetGeneralInformationToRouteTextArea(String s){
generalInformationRouteTextArea.setText(s);
}
+
+ protected ImageIcon generateImageIcon (Color c)
+ {
+ int w = 20;
+ int h =20;
+
+ BufferedImage img = new BufferedImage( w,h, BufferedImage.TYPE_INT_ARGB );
+ // Get a Graphics object
+ Graphics2D g = img.createGraphics();
+
+ // Create white background
+ g.setColor( Color.WHITE );
+ g.fillRect( 0, 0, w,h);
+ g.setColor( Color.BLACK );
+ g.drawRect( 0, 0, w-1,h-1);
+ g.setColor(c);
+ g.fillRect( 1, 1, w-2,h-2 );
+ return new ImageIcon(img);
+ }
/** This method is called from within the constructor to
* initialize the form.
@@ -1586,7 +1620,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
busStopPanel.add(donotUploadButton, gbc_donotUploadButton);
jLabel18 = new javax.swing.JLabel();
- jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/usf/cutr/go_sync/gui/bus_icon.png"))); // NOI18N
+ jLabel18.setIcon(busIcon); // NOI18N
jLabel18.setText("New Stop");
jLabel18.setName("jLabel18"); // NOI18N
GridBagConstraints gbc_jLabel18 = new GridBagConstraints();
@@ -1607,8 +1641,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
gbc_tableStopButton.gridy = 5;
busStopPanel.add(tableStopButton, gbc_tableStopButton);
jLabel15 = new javax.swing.JLabel();
-
- jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/usf/cutr/go_sync/gui/yellow.png"))); // NOI18N
+ jLabel15.setIcon(generateImageIcon(matchColor)); // NOI18N
jLabel15.setText("Potential Match Stops");
jLabel15.setName("jLabel15"); // NOI18N
jLabel15.setOpaque(true);
@@ -1649,7 +1682,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
busStopPanel.add(jLabel3, gbc_jLabel3);
jLabel16 = new javax.swing.JLabel();
- jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/usf/cutr/go_sync/gui/green.png"))); // NOI18N
+ jLabel16.setIcon(generateImageIcon(selectedOSMColor)); // NOI18N
jLabel16.setText("Selected Osm Stop");
jLabel16.setName("jLabel16"); // NOI18N
jLabel16.setOpaque(true);
@@ -1662,7 +1695,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
busStopPanel.add(jLabel16, gbc_jLabel16);
jLabel17 = new javax.swing.JLabel();
- jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/usf/cutr/go_sync/gui/blue.png"))); // NOI18N
+
+ jLabel17.setIcon(generateImageIcon(selectedGTFSColor)); // NOI18N
jLabel17.setText("Selected Gtfs Stop");
jLabel17.setName("jLabel17"); // NOI18N
jLabel17.setOpaque(true);
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/blue.png b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/blue.png
deleted file mode 100644
index f1acd107..00000000
Binary files a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/blue.png and /dev/null differ
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/green.png b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/green.png
deleted file mode 100644
index e3d0bd1a..00000000
Binary files a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/green.png and /dev/null differ
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/yellow.png b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/yellow.png
deleted file mode 100644
index 0b16d778..00000000
Binary files a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/yellow.png and /dev/null differ
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/DefaultOperatorReader.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/DefaultOperatorReader.java
index b0be4353..b95d5524 100644
--- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/DefaultOperatorReader.java
+++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/DefaultOperatorReader.java
@@ -8,6 +8,9 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
import edu.usf.cutr.go_sync.object.DefaultOperator;
import java.util.ArrayList;
import java.util.List;
@@ -18,76 +21,103 @@
*/
public class DefaultOperatorReader {
- public List readOperators(String fName){
-
+
+ private List readOperatorsInternal (BufferedReader br) throws IOException
+ {
String thisLine;
String [] elements;
List ops = new ArrayList();
- try {
- BufferedReader br = new BufferedReader(new FileReader(fName));
- boolean isFirstLine = true;
- while ((thisLine = br.readLine()) != null) {
- if (isFirstLine) {
- isFirstLine = false;
- }
+
+ boolean isFirstLine = true;
+ while ((thisLine = br.readLine()) != null) {
+ if (isFirstLine) {
+ isFirstLine = false;
+ }
+ else {
+ thisLine = thisLine.trim();
+
+ if(thisLine.contains("\"")) {
+ String[] temp = thisLine.split("\"");
+ ArrayList l = new ArrayList();
+ l.add(temp[1].toString());
+ int commas = temp[1].replaceAll("[^,]", "").length();
+
+ elements = thisLine.split(",");
+
+ for(int i = 0; i < elements.length; i++) {
+ if(i > commas) {
+ l.add(elements[i].toString());
+ }
+ }
+ elements = (String[]) l.toArray(new String[0]);
+ }
else {
- thisLine = thisLine.trim();
+ elements = thisLine.split(",");
+ }
+
+
+ DefaultOperator op = new DefaultOperator(elements[0]);
+
+ System.out.print(":: ");
+ for(int i = 0; i < elements.length; i++) {
+ System.out.print(elements[i] + " : ");
- if(thisLine.contains("\"")) {
- String[] temp = thisLine.split("\"");
- ArrayList l = new ArrayList();
- l.add(temp[1].toString());
- int commas = temp[1].replaceAll("[^,]", "").length();
-
- elements = thisLine.split(",");
-
- for(int i = 0; i < elements.length; i++) {
- if(i > commas) {
- l.add(elements[i].toString());
- }
- }
- elements = (String[]) l.toArray(new String[0]);
- }
- else {
- elements = thisLine.split(",");
+ if(i == 1 && elements[1] != null) {
+ op.setOperatorAbbreviation(elements[1]);
}
-
-
- DefaultOperator op = new DefaultOperator(elements[0]);
-
- System.out.print(":: ");
- for(int i = 0; i < elements.length; i++) {
- System.out.print(elements[i] + " : ");
-
- if(i == 1 && elements[1] != null) {
- op.setOperatorAbbreviation(elements[1]);
- }
- if(i == 2 && elements[2] != null) {
- try{
- op.setNtdID(Integer.parseInt(elements[2]));
- } catch(NumberFormatException ex) {
- System.err.println("Error parsing NTD ID " + elements[2] + " - " + ex.getLocalizedMessage());
- }
- }
-
- if(i == 3 && elements[3] != null) {
- op.setGtfsURL(elements[3]);
- }
-
- if(i == 4 && elements[4] != null) {
- try{
- op.setStopDigits(Integer.parseInt(elements[4]));
- } catch(NumberFormatException ex) {
- System.err.println("Error parsing stop digits " + elements[4] + " - " + ex.getLocalizedMessage());
- }
+ if(i == 2 && elements[2] != null) {
+ try{
+ op.setNtdID(Integer.parseInt(elements[2]));
+ } catch(NumberFormatException ex) {
+ System.err.println("Error parsing NTD ID " + elements[2] + " - " + ex.getLocalizedMessage());
}
}
- System.out.println(" :: ");
- ops.add(op);
+ if(i == 3 && elements[3] != null) {
+ op.setGtfsURL(elements[3]);
+ }
+
+ if(i == 4 && elements[4] != null) {
+ try{
+ op.setStopDigits(Integer.parseInt(elements[4]));
+ } catch(NumberFormatException ex) {
+ System.err.println("Error parsing stop digits " + elements[4] + " - " + ex.getLocalizedMessage());
+ }
+ }
}
- }
+ System.out.println(" :: ");
+
+ ops.add(op);
+ }
+ }
+ return ops;
+ }
+
+
+// BufferedReader txtReader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/resources/mytextfile.txt")));
+ public List readOperators(InputStream fName){
+
+
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(fName));
+ List ops = readOperatorsInternal(br);
+ br.close();
+ return ops;
+ }
+ catch (IOException e) {
+ System.err.println("Error reading in default operators: " + e.getLocalizedMessage());
+ return null;
+ }
+}
+
+ public List readOperators(String fName){
+
+
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(fName));
+ List ops = readOperatorsInternal(br);
+ br.close();
return ops;
}
catch (IOException e) {
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java
index d273998f..2eda90f1 100644
--- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java
+++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java
@@ -31,6 +31,8 @@
import edu.usf.cutr.go_sync.object.Route;
import edu.usf.cutr.go_sync.object.Stop;
import edu.usf.cutr.go_sync.tools.OsmFormatter;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
public class GTFSReadIn {
private List stops;
@@ -127,7 +129,7 @@ public List readBusStop(String fName, String agencyName, String routes_fNa
String [] elements;
int stopIdKey=-1, stopNameKey=-1, stopLatKey=-1, stopLonKey=-1;
try {
- BufferedReader br = new BufferedReader(new FileReader(fName));
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fName),"UTF-8"));
boolean isFirstLine = true;
Hashtable keysIndex = new Hashtable();
while ((thisLine = br.readLine()) != null)
@@ -242,7 +244,7 @@ public Hashtable readRoutes(String routes_fName){
String [] elements;
int routeIdKey=-1, routeShortNameKey=-1;
try {
- BufferedReader br = new BufferedReader(new FileReader(routes_fName));
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(routes_fName),"UTF-8"));
boolean isFirstLine = true;
Hashtable keysIndex = new Hashtable();
while ((thisLine = br.readLine()) != null) {
@@ -314,7 +316,7 @@ public Hashtable> matchRouteToStop(String routes_fName, S
// trips.txt read-in
try {
int tripIdKey=-1, routeIdKey=-1;
- BufferedReader br = new BufferedReader(new FileReader(trips_fName));
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(trips_fName),"UTF-8"));
boolean isFirstLine = true;
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
@@ -355,7 +357,7 @@ public Hashtable> matchRouteToStop(String routes_fName, S
// stop_times.txt read-in
int stopIdKey=-1, tripIdKey = -1;
try {
- BufferedReader br = new BufferedReader(new FileReader(stop_times_fName));
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(stop_times_fName),"UTF-8"));
boolean isFirstLine = true;
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/WriteFile.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/WriteFile.java
index 0ef7e3bb..a4c8b736 100644
--- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/WriteFile.java
+++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/WriteFile.java
@@ -47,7 +47,7 @@ public WriteFile(String fname, String contents) {
Writer output = null;
File file = new File(fname);
try {
- output = new BufferedWriter(new FileWriter(file));
+ output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
output.write(contents);
output.close();
System.out.println("Your file: "+fname+" has been written");
@@ -64,7 +64,7 @@ public WriteFile(String fname, Hashtable r) {
Writer output = null;
File file = new File(fname);
try {
- output = new BufferedWriter(new FileWriter(file));
+ output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
reportKeys.addAll(report.keySet());
Iterator it = reportKeys.iterator();
int count = 1;
@@ -223,7 +223,7 @@ public static void exportStops(String fname, Hashtable r, boolean
Writer output = null;
File file = new File(fname);
try {
- output = new BufferedWriter(new FileWriter(file));
+ output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
//print key (first line)
output.write(OperatorInfo.getGtfsFields());
if(!isGtfsFormat) output.write(",OSM_TAGs");
@@ -299,7 +299,7 @@ public void writeStopToFile(String fname, List st){
Writer output = null;
File file = new File(fname);
try {
- output = new BufferedWriter(new FileWriter(file));
+ output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
output.write("stop_id,stop_name,stop_lat,stop_lon\n");
for(int i=0; i