Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update matsim roads #542

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import groovy.sql.Sql
import org.geotools.jdbc.JDBCDataStore
import org.h2gis.utilities.wrapper.ConnectionWrapper
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.io.WKTWriter
import org.matsim.api.core.v01.Coord
import org.matsim.api.core.v01.Id
import org.matsim.api.core.v01.events.*
Expand Down Expand Up @@ -281,7 +282,7 @@ def exec(Connection connection, input) {
);''')
}

PreparedStatement roadStatement = connection.prepareStatement("INSERT INTO " + outTableName + " (LINK_ID, OSM_ID, THE_GEOM) VALUES (?, ?, ST_GeomFromText(?, " + SRID + "))")
PreparedStatement roadStatement = connection.prepareStatement("INSERT INTO " + outTableName + " (LINK_ID, OSM_ID, THE_GEOM) VALUES (?, ?, ST_UpdateZ(ST_GeomFromText(?, " + SRID + "),0.05))")
PreparedStatement lwStatement = connection.prepareStatement("INSERT INTO " + lwTableName + " (LINK_ID, LW63, LW125, LW250, LW500, LW1000, LW2000, LW4000, LW8000, TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
PreparedStatement trafficStatement = connection.prepareStatement("INSERT INTO " + trafficTableName + " (LINK_ID, LV_D, LV_SPD_D, MV_D, MV_SPD_D, HGV_D, HGV_SPD_D, TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
PreparedStatement contribStatement;
Expand Down Expand Up @@ -776,45 +777,27 @@ class LinkStatStruct {
Coord[] coords = ((Coord[]) link.getAttributes().getAttribute("geometry"))
Coordinate[] result = new Coordinate[coords.length]
for (int i = 0; i < coords.length; i++) {
result[i] = new Coordinate(coords[i].getX(), coords[i].getY(), 0.5)
result[i] = new Coordinate(coords[i].getX(), coords[i].getY(), 0.05)
}
return result
} else {
Coordinate[] result = new Coordinate[2]
result[0] = new Coordinate(
link.getFromNode().getCoord().getX(),
link.getFromNode().getCoord().getY(),
0.5
0.05
)
result[1] = new Coordinate(
link.getToNode().getCoord().getX(),
link.getToNode().getCoord().getY(),
0.5
0.05
)
return result
}
}

String getGeometryString() {
if (link.getAttributes().getAsMap().containsKey("geometry")) {
Coord[] coords = ((Coord[]) link.getAttributes().getAttribute("geometry"))
String result = "LINESTRING ("
for (int i = 0; i < coords.length; i++) {
if (i > 0) {
result += ", "
}
result += coords[i].getX() + " " + coords[i].getY()
}
result += ")"
return result
} else {
String result = "LINESTRING ("
result += link.getFromNode().getCoord().getX() + " " + link.getFromNode().getCoord().getY()
result += ", "
result += link.getToNode().getCoord().getX() + " " + link.getToNode().getCoord().getY()
result += ")"
return result
}
Coordinate[] points = getGeometry()
return WKTWriter.toLineString(points);
}

String getOsmId() {
Expand Down