Definition at line 15 of file SUMOSAXNeworkfileHandler.java.
Public Member Functions | |
| void | characters (char ch[], int start, int length) |
| void | endElement (String uri, String localName, String qName) throws SAXException |
| void | startElement (String uri, String localName, String qName, Attributes attributes) throws SAXException |
Data Fields | |
| SUMONetwork | network = new SUMONetwork() |
Private Attributes | |
| String | cEdgeId |
| int | currentElementType |
| String | junctionId |
| String | sumoEdgeId |
| String | sumoLaneId |
Static Private Attributes | |
| static int | CEDGE = 3 |
| static int | EDGE = 1 |
| static int | JUNCTION = 4 |
| static int | LANE = 2 |
| static int | OFFSET = 5 |
| static int | PROJ = 6 |
| static int | UNKNOWN = 0 |
| void de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::characters | ( | char | ch[], | |
| int | start, | |||
| int | length | |||
| ) | [inline] |
Definition at line 77 of file SUMOSAXNeworkfileHandler.java.
References currentElementType, LANE, de::psi::telco::sumoplayer::SUMONetwork::lanes, network, de::psi::telco::sumoplayer::SUMONetwork::offset, OFFSET, PROJ, de::psi::telco::sumoplayer::SUMONetwork::projString, and sumoLaneId.
00077 { 00078 00079 if (currentElementType == LANE){ // read coords from lane 00080 00081 char[] chars = new char[length]; // copy stuff from sax buffer 00082 for (int i = 0; i<length; i++){ 00083 chars[i] = ch[start+i]; 00084 } 00085 String data = new String(chars); 00086 00087 String[] coordPairs = data.split(" "); // split by pairs ( COORD1X,COORD1Y COORD2X,COORD2Y ...) 00088 for (int i = 0 ; i < coordPairs.length; i++){ 00089 String[] coordElements = coordPairs[i].split(","); 00090 if (coordElements != null && coordElements.length == 2){ // split by comma ( COORD1X,COORD1Y ) 00091 try{ 00092 double x = Double.parseDouble(coordElements[0]); 00093 double y = Double.parseDouble(coordElements[1]); 00094 00095 network.lanes.get(sumoLaneId).points.add(new PointImpl(x,y)); 00096 }catch(NumberFormatException e){ 00097 } 00098 } 00099 } 00100 00101 }else if (currentElementType == OFFSET){ // read offset. i.e: <net-offset>-755969.000000,-5660071.000000</net-offset> 00102 char[] chars = new char[length]; // copy stuff from sax buffer 00103 for (int i = 0; i<length; i++){ 00104 chars[i] = ch[start+i]; 00105 } 00106 String data = new String(chars); 00107 String[] vectorElements = data.split(","); 00108 if (vectorElements.length==2){ 00109 network.offset = new PointImpl(Double.parseDouble(vectorElements[0]),Double.parseDouble(vectorElements[1])); 00110 } 00111 }else if (currentElementType == PROJ){ // read projection string. i.e: <orig-proj>+proj=utm +ellps=bessel +units=m</orig-proj> 00112 char[] chars = new char[length]; // copy stuff from sax buffer 00113 for (int i = 0; i<length; i++){ 00114 chars[i] = ch[start+i]; 00115 } 00116 network.projString = new String(chars); 00117 } 00118 }
| void de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::endElement | ( | String | uri, | |
| String | localName, | |||
| String | qName | |||
| ) | throws SAXException [inline] |
Definition at line 72 of file SUMOSAXNeworkfileHandler.java.
References currentElementType, and UNKNOWN.
00072 { 00073 this.currentElementType = UNKNOWN; 00074 }
| void de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::startElement | ( | String | uri, | |
| String | localName, | |||
| String | qName, | |||
| Attributes | attributes | |||
| ) | throws SAXException [inline] |
Definition at line 36 of file SUMOSAXNeworkfileHandler.java.
References CEDGE, cEdgeId, currentElementType, EDGE, LANE, de::psi::telco::sumoplayer::SUMONetwork::lanes, network, OFFSET, PROJ, sumoEdgeId, and sumoLaneId.
00036 { 00037 if (qName.equals("edge")){ 00038 this.currentElementType = EDGE; 00039 sumoEdgeId = attributes.getValue("id"); 00040 00041 }else if (qName.equals("lane")){ 00042 this.currentElementType = LANE; 00043 sumoLaneId = attributes.getValue("id"); 00044 00045 network.lanes.put(sumoLaneId, new SUMOLane(sumoLaneId)); 00046 00047 }else if (qName.equals("cedge")){ // cedges seem to be mappings from sumo.edg.xml IDs to sumoIDs 00048 this.currentElementType = CEDGE; 00049 cEdgeId = attributes.getValue("id"); 00050 } 00051 00052 /* // note junctions not interesting. all coordinates are stored within lanes 00053 else if (qName.equals("junction")){ // junction found. add it 00054 this.currentEementType = JUNCTION; 00055 00056 // i.e. <junction id="124667945" type="priority" x="3186.50" y="17778.50">...</junction> 00057 junctionId = attributes.getValue("id"); 00058 double x = Double.parseDouble(attributes.getValue("x")); 00059 double y = Double.parseDouble(attributes.getValue("y")); 00060 network.addJunction(junctionId, x, y); 00061 }*/ 00062 00063 // some network cfg 00064 else if (qName.equals("net-offset")){ 00065 this.currentElementType = OFFSET; 00066 }else if (qName.equals("orig-proj")){ 00067 this.currentElementType = PROJ; 00068 } 00069 00070 }
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::CEDGE = 3 [static, private] |
String de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::cEdgeId [private] |
Definition at line 28 of file SUMOSAXNeworkfileHandler.java.
Referenced by characters(), endElement(), and startElement().
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::EDGE = 1 [static, private] |
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::JUNCTION = 4 [static, private] |
Definition at line 25 of file SUMOSAXNeworkfileHandler.java.
String de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::junctionId [private] |
Definition at line 34 of file SUMOSAXNeworkfileHandler.java.
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::LANE = 2 [static, private] |
Definition at line 23 of file SUMOSAXNeworkfileHandler.java.
Referenced by characters(), and startElement().
Definition at line 18 of file SUMOSAXNeworkfileHandler.java.
Referenced by characters(), de::psi::telco::sumoplayer::SUMOGeoCoordinatesResolver::readNetwork(), and startElement().
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::OFFSET = 5 [static, private] |
Definition at line 26 of file SUMOSAXNeworkfileHandler.java.
Referenced by characters(), and startElement().
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::PROJ = 6 [static, private] |
Definition at line 27 of file SUMOSAXNeworkfileHandler.java.
Referenced by characters(), and startElement().
String de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::sumoEdgeId [private] |
String de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::sumoLaneId [private] |
Definition at line 32 of file SUMOSAXNeworkfileHandler.java.
Referenced by characters(), and startElement().
int de::psi::telco::sumoplayer::SUMOSAXNeworkfileHandler::UNKNOWN = 0 [static, private] |
1.5.6