repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
orbisgis/h2gis
h2gis-network/src/main/java/org/h2gis/network/functions/GraphFunctionParser.java
GraphFunctionParser.parseEdgeOrientation
protected String parseEdgeOrientation(String v) { if (v == null) { return null; } if (!v.contains(SEPARATOR)) { throw new IllegalArgumentException(ORIENTATION_ERROR); } // Extract the global and edge orientations. String[] s = v.split(SEPARATOR); if (s.length == 2) { // Return just the edge orientation column name and not the // global orientation. return s[1].trim(); } else { throw new IllegalArgumentException(ORIENTATION_ERROR); } }
java
protected String parseEdgeOrientation(String v) { if (v == null) { return null; } if (!v.contains(SEPARATOR)) { throw new IllegalArgumentException(ORIENTATION_ERROR); } // Extract the global and edge orientations. String[] s = v.split(SEPARATOR); if (s.length == 2) { // Return just the edge orientation column name and not the // global orientation. return s[1].trim(); } else { throw new IllegalArgumentException(ORIENTATION_ERROR); } }
[ "protected", "String", "parseEdgeOrientation", "(", "String", "v", ")", "{", "if", "(", "v", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "v", ".", "contains", "(", "SEPARATOR", ")", ")", "{", "throw", "new", "IllegalArgumentExce...
Recovers the edge orientation from a string. @param v String @return The edge orientation
[ "Recovers", "the", "edge", "orientation", "from", "a", "string", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-network/src/main/java/org/h2gis/network/functions/GraphFunctionParser.java#L125-L141
train
orbisgis/h2gis
h2gis-network/src/main/java/org/h2gis/network/functions/GraphFunctionParser.java
GraphFunctionParser.parseDestinationsString
public static int[] parseDestinationsString(String s) { if (!s.contains(",")) { return new int[]{Integer.valueOf(s.trim())}; } String[] array = s.split(","); int[] destinations = new int[array.length]; for (int i = 0; i < destinations.length; i++) { final String stringWithNoWhiteSpaces = array[i].replaceAll("\\s", ""); if (stringWithNoWhiteSpaces.isEmpty()) { throw new IllegalArgumentException("Empty destination. Too many commas?"); } destinations[i] = Integer.valueOf(stringWithNoWhiteSpaces); } return destinations; }
java
public static int[] parseDestinationsString(String s) { if (!s.contains(",")) { return new int[]{Integer.valueOf(s.trim())}; } String[] array = s.split(","); int[] destinations = new int[array.length]; for (int i = 0; i < destinations.length; i++) { final String stringWithNoWhiteSpaces = array[i].replaceAll("\\s", ""); if (stringWithNoWhiteSpaces.isEmpty()) { throw new IllegalArgumentException("Empty destination. Too many commas?"); } destinations[i] = Integer.valueOf(stringWithNoWhiteSpaces); } return destinations; }
[ "public", "static", "int", "[", "]", "parseDestinationsString", "(", "String", "s", ")", "{", "if", "(", "!", "s", ".", "contains", "(", "\",\"", ")", ")", "{", "return", "new", "int", "[", "]", "{", "Integer", ".", "valueOf", "(", "s", ".", "trim"...
Returns an array of destination ids from a comma-separated list of destinations. @param s Comma-separated list of destinations @return An array of destination ids
[ "Returns", "an", "array", "of", "destination", "ids", "from", "a", "comma", "-", "separated", "list", "of", "destinations", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-network/src/main/java/org/h2gis/network/functions/GraphFunctionParser.java#L225-L239
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserTrk.java
AbstractGpxParserTrk.initialise
public void initialise(XMLReader reader, AbstractGpxParserDefault parent) { setReader(reader); setParent(parent); setContentBuffer(parent.getContentBuffer()); setTrkPreparedStmt(parent.getTrkPreparedStmt()); setTrkSegmentsPreparedStmt(parent.getTrkSegmentsPreparedStmt()); setTrkPointsPreparedStmt(parent.getTrkPointsPreparedStmt()); setElementNames(parent.getElementNames()); setCurrentLine(parent.getCurrentLine()); setTrksegList(new ArrayList<Coordinate>()); setTrkList(new ArrayList<LineString>()); }
java
public void initialise(XMLReader reader, AbstractGpxParserDefault parent) { setReader(reader); setParent(parent); setContentBuffer(parent.getContentBuffer()); setTrkPreparedStmt(parent.getTrkPreparedStmt()); setTrkSegmentsPreparedStmt(parent.getTrkSegmentsPreparedStmt()); setTrkPointsPreparedStmt(parent.getTrkPointsPreparedStmt()); setElementNames(parent.getElementNames()); setCurrentLine(parent.getCurrentLine()); setTrksegList(new ArrayList<Coordinate>()); setTrkList(new ArrayList<LineString>()); }
[ "public", "void", "initialise", "(", "XMLReader", "reader", ",", "AbstractGpxParserDefault", "parent", ")", "{", "setReader", "(", "reader", ")", ";", "setParent", "(", "parent", ")", ";", "setContentBuffer", "(", "parent", ".", "getContentBuffer", "(", ")", "...
Create a new specific parser. It has in memory the default parser, the contentBuffer, the elementNames, the currentLine and the trkID. @param reader The XMLReader used in the default class @param parent The parser used in the default class
[ "Create", "a", "new", "specific", "parser", ".", "It", "has", "in", "memory", "the", "default", "parser", "the", "contentBuffer", "the", "elementNames", "the", "currentLine", "and", "the", "trkID", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserTrk.java#L66-L77
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_GeomFromGeoJSON.java
ST_GeomFromGeoJSON.geomFromGeoJSON
public static Geometry geomFromGeoJSON(String geojson) throws IOException, SQLException { if (geojson == null) { return null; } if (jsFactory == null) { jsFactory = new JsonFactory(); jsFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true); jsFactory.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); jsFactory.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true); reader = new GJGeometryReader(new GeometryFactory()); } JsonParser jp = jsFactory.createParser(geojson); return reader.parseGeometry(jp); }
java
public static Geometry geomFromGeoJSON(String geojson) throws IOException, SQLException { if (geojson == null) { return null; } if (jsFactory == null) { jsFactory = new JsonFactory(); jsFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true); jsFactory.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); jsFactory.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true); reader = new GJGeometryReader(new GeometryFactory()); } JsonParser jp = jsFactory.createParser(geojson); return reader.parseGeometry(jp); }
[ "public", "static", "Geometry", "geomFromGeoJSON", "(", "String", "geojson", ")", "throws", "IOException", ",", "SQLException", "{", "if", "(", "geojson", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "jsFactory", "==", "null", ")", "{", ...
Convert a geojson geometry to geometry. @param geojson @return @throws java.io.IOException @throws java.sql.SQLException
[ "Convert", "a", "geojson", "geometry", "to", "geometry", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_GeomFromGeoJSON.java#L58-L71
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_Perimeter.java
ST_Perimeter.perimeter
public static Double perimeter(Geometry geometry){ if(geometry==null){ return null; } if(geometry.getDimension()<2){ return 0d; } return computePerimeter(geometry); }
java
public static Double perimeter(Geometry geometry){ if(geometry==null){ return null; } if(geometry.getDimension()<2){ return 0d; } return computePerimeter(geometry); }
[ "public", "static", "Double", "perimeter", "(", "Geometry", "geometry", ")", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "geometry", ".", "getDimension", "(", ")", "<", "2", ")", "{", "return", "0d", ";"...
Compute the perimeter of a polygon or a multipolygon. @param geometry @return
[ "Compute", "the", "perimeter", "of", "a", "polygon", "or", "a", "multipolygon", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_Perimeter.java#L50-L58
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_Perimeter.java
ST_Perimeter.computePerimeter
private static double computePerimeter(Geometry geometry) { double sum = 0; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry subGeom = geometry.getGeometryN(i); if (subGeom instanceof Polygon) { sum += ((Polygon) subGeom).getExteriorRing().getLength(); } } return sum; }
java
private static double computePerimeter(Geometry geometry) { double sum = 0; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry subGeom = geometry.getGeometryN(i); if (subGeom instanceof Polygon) { sum += ((Polygon) subGeom).getExteriorRing().getLength(); } } return sum; }
[ "private", "static", "double", "computePerimeter", "(", "Geometry", "geometry", ")", "{", "double", "sum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "geometry", ".", "getNumGeometries", "(", ")", ";", "i", "++", ")", "{", "Geome...
Compute the perimeter @param geometry @return
[ "Compute", "the", "perimeter" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_Perimeter.java#L65-L74
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_YMin.java
ST_YMin.getMinY
public static Double getMinY(Geometry geom) { if (geom != null) { return geom.getEnvelopeInternal().getMinY(); } else { return null; } }
java
public static Double getMinY(Geometry geom) { if (geom != null) { return geom.getEnvelopeInternal().getMinY(); } else { return null; } }
[ "public", "static", "Double", "getMinY", "(", "Geometry", "geom", ")", "{", "if", "(", "geom", "!=", "null", ")", "{", "return", "geom", ".", "getEnvelopeInternal", "(", ")", ".", "getMinY", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}"...
Returns the minimal y-value of the given geometry. @param geom Geometry @return The minimal y-value of the given geometry, or null if the geometry is null.
[ "Returns", "the", "minimal", "y", "-", "value", "of", "the", "given", "geometry", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_YMin.java#L48-L54
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/generalize/ST_SimplifyPreserveTopology.java
ST_SimplifyPreserveTopology.simplyPreserve
public static Geometry simplyPreserve(Geometry geometry, double distance) { if(geometry == null){ return null; } return TopologyPreservingSimplifier.simplify(geometry, distance); }
java
public static Geometry simplyPreserve(Geometry geometry, double distance) { if(geometry == null){ return null; } return TopologyPreservingSimplifier.simplify(geometry, distance); }
[ "public", "static", "Geometry", "simplyPreserve", "(", "Geometry", "geometry", ",", "double", "distance", ")", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "return", "TopologyPreservingSimplifier", ".", "simplify", "(", "geom...
Simplifies a geometry and ensures that the result is a valid geometry having the same dimension and number of components as the input, and with the components having the same topological relationship. @param geometry @param distance @return
[ "Simplifies", "a", "geometry", "and", "ensures", "that", "the", "result", "is", "a", "valid", "geometry", "having", "the", "same", "dimension", "and", "number", "of", "components", "as", "the", "input", "and", "with", "the", "components", "having", "the", "s...
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/generalize/ST_SimplifyPreserveTopology.java#L51-L56
train
orbisgis/h2gis
h2gis-network/src/main/java/org/h2gis/network/functions/GraphFunction.java
GraphFunction.prepareGraph
protected static KeyedGraph prepareGraph(Connection connection, String inputTable, String orientation, String weight, Class vertexClass, Class edgeClass) throws SQLException { GraphFunctionParser parser = new GraphFunctionParser(); parser.parseWeightAndOrientation(orientation, weight); return new GraphCreator(connection, inputTable, parser.getGlobalOrientation(), parser.getEdgeOrientation(), parser.getWeightColumn(), vertexClass, edgeClass).prepareGraph(); }
java
protected static KeyedGraph prepareGraph(Connection connection, String inputTable, String orientation, String weight, Class vertexClass, Class edgeClass) throws SQLException { GraphFunctionParser parser = new GraphFunctionParser(); parser.parseWeightAndOrientation(orientation, weight); return new GraphCreator(connection, inputTable, parser.getGlobalOrientation(), parser.getEdgeOrientation(), parser.getWeightColumn(), vertexClass, edgeClass).prepareGraph(); }
[ "protected", "static", "KeyedGraph", "prepareGraph", "(", "Connection", "connection", ",", "String", "inputTable", ",", "String", "orientation", ",", "String", "weight", ",", "Class", "vertexClass", ",", "Class", "edgeClass", ")", "throws", "SQLException", "{", "G...
Return a JGraphT graph from the input edges table. @param connection Connection @param inputTable Input table name @param orientation Orientation string @param weight Weight column name, null for unweighted graphs @param vertexClass @param edgeClass @return Graph @throws java.sql.SQLException
[ "Return", "a", "JGraphT", "graph", "from", "the", "input", "edges", "table", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-network/src/main/java/org/h2gis/network/functions/GraphFunction.java#L50-L64
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java
GridRowSet.getCellPolygon
private Polygon getCellPolygon() { final Coordinate[] summits = new Coordinate[5]; double x1 = minX + cellI * deltaX; double y1 = minY + cellJ * deltaY; double x2 = minX + (cellI + 1) * deltaX; double y2 = minY + (cellJ + 1) * deltaY; summits[0] = new Coordinate(x1, y1); summits[1] = new Coordinate(x2, y1); summits[2] = new Coordinate(x2, y2); summits[3] = new Coordinate(x1, y2); summits[4] = new Coordinate(x1, y1); final LinearRing g = GF.createLinearRing(summits); final Polygon gg = GF.createPolygon(g, null); cellI++; return gg; }
java
private Polygon getCellPolygon() { final Coordinate[] summits = new Coordinate[5]; double x1 = minX + cellI * deltaX; double y1 = minY + cellJ * deltaY; double x2 = minX + (cellI + 1) * deltaX; double y2 = minY + (cellJ + 1) * deltaY; summits[0] = new Coordinate(x1, y1); summits[1] = new Coordinate(x2, y1); summits[2] = new Coordinate(x2, y2); summits[3] = new Coordinate(x1, y2); summits[4] = new Coordinate(x1, y1); final LinearRing g = GF.createLinearRing(summits); final Polygon gg = GF.createPolygon(g, null); cellI++; return gg; }
[ "private", "Polygon", "getCellPolygon", "(", ")", "{", "final", "Coordinate", "[", "]", "summits", "=", "new", "Coordinate", "[", "5", "]", ";", "double", "x1", "=", "minX", "+", "cellI", "*", "deltaX", ";", "double", "y1", "=", "minY", "+", "cellJ", ...
Compute the polygon corresponding to the cell @return Polygon of the cell
[ "Compute", "the", "polygon", "corresponding", "to", "the", "cell" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java#L143-L158
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java
GridRowSet.getCellPoint
private Point getCellPoint() { double x1 = (minX + cellI * deltaX) + (deltaX / 2d); double y1 = (minY + cellJ * deltaY) + (deltaY / 2d); cellI++; return GF.createPoint(new Coordinate(x1, y1)); }
java
private Point getCellPoint() { double x1 = (minX + cellI * deltaX) + (deltaX / 2d); double y1 = (minY + cellJ * deltaY) + (deltaY / 2d); cellI++; return GF.createPoint(new Coordinate(x1, y1)); }
[ "private", "Point", "getCellPoint", "(", ")", "{", "double", "x1", "=", "(", "minX", "+", "cellI", "*", "deltaX", ")", "+", "(", "deltaX", "/", "2d", ")", ";", "double", "y1", "=", "(", "minY", "+", "cellJ", "*", "deltaY", ")", "+", "(", "deltaY"...
Compute the point of the cell @return Center point of the cell
[ "Compute", "the", "point", "of", "the", "cell" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java#L165-L170
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java
GridRowSet.getFirstGeometryField
private static String getFirstGeometryField(String tableName, Connection connection) throws SQLException { // Find first geometry column List<String> geomFields = SFSUtilities.getGeometryFields(connection, TableLocation.parse(tableName, JDBCUtilities.isH2DataBase(connection.getMetaData()))); if (!geomFields.isEmpty()) { return geomFields.get(0); } else { throw new SQLException("The table " + tableName + " does not contain a geometry field"); } }
java
private static String getFirstGeometryField(String tableName, Connection connection) throws SQLException { // Find first geometry column List<String> geomFields = SFSUtilities.getGeometryFields(connection, TableLocation.parse(tableName, JDBCUtilities.isH2DataBase(connection.getMetaData()))); if (!geomFields.isEmpty()) { return geomFields.get(0); } else { throw new SQLException("The table " + tableName + " does not contain a geometry field"); } }
[ "private", "static", "String", "getFirstGeometryField", "(", "String", "tableName", ",", "Connection", "connection", ")", "throws", "SQLException", "{", "// Find first geometry column", "List", "<", "String", ">", "geomFields", "=", "SFSUtilities", ".", "getGeometryFiel...
Return the first spatial geometry field name @param tableName @param connection @return the name of the first geometry column @throws SQLException
[ "Return", "the", "first", "spatial", "geometry", "field", "name" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java#L198-L206
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java
GridRowSet.initParameters
private void initParameters() { this.minX = envelope.getMinX(); this.minY = envelope.getMinY(); double cellWidth = envelope.getWidth(); double cellHeight = envelope.getHeight(); this.maxI = (int) Math.ceil(cellWidth / deltaX); this.maxJ = (int) Math.ceil(cellHeight / deltaY); }
java
private void initParameters() { this.minX = envelope.getMinX(); this.minY = envelope.getMinY(); double cellWidth = envelope.getWidth(); double cellHeight = envelope.getHeight(); this.maxI = (int) Math.ceil(cellWidth / deltaX); this.maxJ = (int) Math.ceil(cellHeight / deltaY); }
[ "private", "void", "initParameters", "(", ")", "{", "this", ".", "minX", "=", "envelope", ".", "getMinX", "(", ")", ";", "this", ".", "minY", "=", "envelope", ".", "getMinY", "(", ")", ";", "double", "cellWidth", "=", "envelope", ".", "getWidth", "(", ...
Compute the parameters need to create each cells
[ "Compute", "the", "parameters", "need", "to", "create", "each", "cells" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java#L212-L221
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java
GridRowSet.getResultSet
public ResultSet getResultSet() throws SQLException { SimpleResultSet srs = new SimpleResultSet(this); srs.addColumn("THE_GEOM", Types.JAVA_OBJECT, "GEOMETRY", 0, 0); srs.addColumn("ID", Types.INTEGER, 10, 0); srs.addColumn("ID_COL", Types.INTEGER, 10, 0); srs.addColumn("ID_ROW", Types.INTEGER, 10, 0); return srs; }
java
public ResultSet getResultSet() throws SQLException { SimpleResultSet srs = new SimpleResultSet(this); srs.addColumn("THE_GEOM", Types.JAVA_OBJECT, "GEOMETRY", 0, 0); srs.addColumn("ID", Types.INTEGER, 10, 0); srs.addColumn("ID_COL", Types.INTEGER, 10, 0); srs.addColumn("ID_ROW", Types.INTEGER, 10, 0); return srs; }
[ "public", "ResultSet", "getResultSet", "(", ")", "throws", "SQLException", "{", "SimpleResultSet", "srs", "=", "new", "SimpleResultSet", "(", "this", ")", ";", "srs", ".", "addColumn", "(", "\"THE_GEOM\"", ",", "Types", ".", "JAVA_OBJECT", ",", "\"GEOMETRY\"", ...
Give the regular grid @return ResultSet @throws SQLException
[ "Give", "the", "regular", "grid" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/GridRowSet.java#L229-L236
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/trigonometry/ST_Azimuth.java
ST_Azimuth.azimuth
public static Double azimuth(Geometry pointA, Geometry pointB){ if(pointA == null||pointB == null){ return null; } if ((pointA instanceof Point) && (pointB instanceof Point)) { Double angle ; double x0 = ((Point) pointA).getX(); double y0 = ((Point) pointA).getY(); double x1 = ((Point) pointB).getX(); double y1 = ((Point) pointB).getY(); if (x0 == x1) { if (y0 < y1) { angle = 0.0; } else if (y0 > y1) { angle = Math.PI; } else { angle = null; } } else if (y0 == y1) { if (x0 < x1) { angle = Math.PI / 2; } else if (x0 > x1) { angle = Math.PI + (Math.PI / 2); } else { angle = null; } } else if (x0 < x1) { if (y0 < y1) { angle = Math.atan(Math.abs(x0 - x1) / Math.abs(y0 - y1)); } else { /* ( y0 > y1 ) - equality case handled above */ angle = Math.atan(Math.abs(y0 - y1) / Math.abs(x0 - x1)) + (Math.PI / 2); } } else { /* ( x0 > x1 ) - equality case handled above */ if (y0 > y1) { angle = Math.atan(Math.abs(x0 - x1) / Math.abs(y0 - y1)) + Math.PI; } else { /* ( y0 < y1 ) - equality case handled above */ angle = Math.atan(Math.abs(y0 - y1) / Math.abs(x0 - x1)) + (Math.PI + (Math.PI / 2)); } } return angle; } return null; }
java
public static Double azimuth(Geometry pointA, Geometry pointB){ if(pointA == null||pointB == null){ return null; } if ((pointA instanceof Point) && (pointB instanceof Point)) { Double angle ; double x0 = ((Point) pointA).getX(); double y0 = ((Point) pointA).getY(); double x1 = ((Point) pointB).getX(); double y1 = ((Point) pointB).getY(); if (x0 == x1) { if (y0 < y1) { angle = 0.0; } else if (y0 > y1) { angle = Math.PI; } else { angle = null; } } else if (y0 == y1) { if (x0 < x1) { angle = Math.PI / 2; } else if (x0 > x1) { angle = Math.PI + (Math.PI / 2); } else { angle = null; } } else if (x0 < x1) { if (y0 < y1) { angle = Math.atan(Math.abs(x0 - x1) / Math.abs(y0 - y1)); } else { /* ( y0 > y1 ) - equality case handled above */ angle = Math.atan(Math.abs(y0 - y1) / Math.abs(x0 - x1)) + (Math.PI / 2); } } else { /* ( x0 > x1 ) - equality case handled above */ if (y0 > y1) { angle = Math.atan(Math.abs(x0 - x1) / Math.abs(y0 - y1)) + Math.PI; } else { /* ( y0 < y1 ) - equality case handled above */ angle = Math.atan(Math.abs(y0 - y1) / Math.abs(x0 - x1)) + (Math.PI + (Math.PI / 2)); } } return angle; } return null; }
[ "public", "static", "Double", "azimuth", "(", "Geometry", "pointA", ",", "Geometry", "pointB", ")", "{", "if", "(", "pointA", "==", "null", "||", "pointB", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "(", "pointA", "instanceof", "Poi...
This code compute the angle in radian as postgis does. @author : Jose Martinez-Llario from JASPA. JAva SPAtial for SQL @param pointA @param pointB @return
[ "This", "code", "compute", "the", "angle", "in", "radian", "as", "postgis", "does", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/trigonometry/ST_Azimuth.java#L53-L102
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_YMax.java
ST_YMax.getMaxY
public static Double getMaxY(Geometry geom) { if (geom != null) { return geom.getEnvelopeInternal().getMaxY(); } else { return null; } }
java
public static Double getMaxY(Geometry geom) { if (geom != null) { return geom.getEnvelopeInternal().getMaxY(); } else { return null; } }
[ "public", "static", "Double", "getMaxY", "(", "Geometry", "geom", ")", "{", "if", "(", "geom", "!=", "null", ")", "{", "return", "geom", ".", "getEnvelopeInternal", "(", ")", ".", "getMaxY", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}"...
Returns the maximal y-value of the given geometry. @param geom Geometry @return The maximal y-value of the given geometry, or null if the geometry is null.
[ "Returns", "the", "maximal", "y", "-", "value", "of", "the", "given", "geometry", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_YMax.java#L48-L54
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/GJGeometryReader.java
GJGeometryReader.parsePoint
private Point parsePoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ to parse the coordinate Point point = GF.createPoint(parseCoordinate(jp)); jp.nextToken(); return point; } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }
java
private Point parsePoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ to parse the coordinate Point point = GF.createPoint(parseCoordinate(jp)); jp.nextToken(); return point; } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }
[ "private", "Point", "parsePoint", "(", "JsonParser", "jp", ")", "throws", "IOException", ",", "SQLException", "{", "jp", ".", "nextToken", "(", ")", ";", "// FIELD_NAME coordinates ", "String", "coordinatesField", "=", "jp", ".", "getText", "(", ")", ";",...
Parses one position Syntax: { "type": "Point", "coordinates": [100.0, 0.0] } @param jsParser @throws IOException @return Point
[ "Parses", "one", "position" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/GJGeometryReader.java#L91-L102
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/GJGeometryReader.java
GJGeometryReader.parseMultiPoint
private MultiPoint parseMultiPoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ coordinates MultiPoint mPoint = GF.createMultiPoint(parseCoordinates(jp)); jp.nextToken();//END_OBJECT } geometry return mPoint; } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }
java
private MultiPoint parseMultiPoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ coordinates MultiPoint mPoint = GF.createMultiPoint(parseCoordinates(jp)); jp.nextToken();//END_OBJECT } geometry return mPoint; } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }
[ "private", "MultiPoint", "parseMultiPoint", "(", "JsonParser", "jp", ")", "throws", "IOException", ",", "SQLException", "{", "jp", ".", "nextToken", "(", ")", ";", "// FIELD_NAME coordinates ", "String", "coordinatesField", "=", "jp", ".", "getText", "(", "...
Parses an array of positions Syntax: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] } @param jsParser @throws IOException @return MultiPoint
[ "Parses", "an", "array", "of", "positions" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/GJGeometryReader.java#L115-L126
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/GJGeometryReader.java
GJGeometryReader.parseCoordinate
private Coordinate parseCoordinate(JsonParser jp) throws IOException { jp.nextToken(); double x = jp.getDoubleValue();// VALUE_NUMBER_FLOAT jp.nextToken(); // second value double y = jp.getDoubleValue(); Coordinate coord; //We look for a z value jp.nextToken(); if (jp.getCurrentToken() == JsonToken.END_ARRAY) { coord = new Coordinate(x, y); } else { double z = jp.getDoubleValue(); jp.nextToken(); // exit array coord = new Coordinate(x, y, z); } jp.nextToken(); return coord; }
java
private Coordinate parseCoordinate(JsonParser jp) throws IOException { jp.nextToken(); double x = jp.getDoubleValue();// VALUE_NUMBER_FLOAT jp.nextToken(); // second value double y = jp.getDoubleValue(); Coordinate coord; //We look for a z value jp.nextToken(); if (jp.getCurrentToken() == JsonToken.END_ARRAY) { coord = new Coordinate(x, y); } else { double z = jp.getDoubleValue(); jp.nextToken(); // exit array coord = new Coordinate(x, y, z); } jp.nextToken(); return coord; }
[ "private", "Coordinate", "parseCoordinate", "(", "JsonParser", "jp", ")", "throws", "IOException", "{", "jp", ".", "nextToken", "(", ")", ";", "double", "x", "=", "jp", ".", "getDoubleValue", "(", ")", ";", "// VALUE_NUMBER_FLOAT", "jp", ".", "nextToken", "(...
Parses a GeoJSON coordinate array and returns a JTS coordinate. The first token corresponds to the first X value. The last token correponds to the end of the coordinate array "]". Parsed syntax: 100.0, 0.0] @param jp @throws IOException @return Coordinate
[ "Parses", "a", "GeoJSON", "coordinate", "array", "and", "returns", "a", "JTS", "coordinate", ".", "The", "first", "token", "corresponds", "to", "the", "first", "X", "value", ".", "The", "last", "token", "correponds", "to", "the", "end", "of", "the", "coord...
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/GJGeometryReader.java#L348-L365
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_ToMultiLine.java
ST_ToMultiLine.createMultiLineString
public static MultiLineString createMultiLineString(Geometry geom) throws SQLException { if (geom != null) { if (geom.getDimension() > 0) { final List<LineString> lineStrings = new LinkedList<LineString>(); toMultiLineString(geom, lineStrings); return GEOMETRY_FACTORY.createMultiLineString( lineStrings.toArray(new LineString[0])); } else { return GEOMETRY_FACTORY.createMultiLineString(null); } } else { return null; } }
java
public static MultiLineString createMultiLineString(Geometry geom) throws SQLException { if (geom != null) { if (geom.getDimension() > 0) { final List<LineString> lineStrings = new LinkedList<LineString>(); toMultiLineString(geom, lineStrings); return GEOMETRY_FACTORY.createMultiLineString( lineStrings.toArray(new LineString[0])); } else { return GEOMETRY_FACTORY.createMultiLineString(null); } } else { return null; } }
[ "public", "static", "MultiLineString", "createMultiLineString", "(", "Geometry", "geom", ")", "throws", "SQLException", "{", "if", "(", "geom", "!=", "null", ")", "{", "if", "(", "geom", ".", "getDimension", "(", ")", ">", "0", ")", "{", "final", "List", ...
Constructs a MultiLineString from the given geometry's coordinates. @param geom Geometry @return A MultiLineString constructed from the given geometry's coordinates @throws SQLException
[ "Constructs", "a", "MultiLineString", "from", "the", "given", "geometry", "s", "coordinates", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_ToMultiLine.java#L58-L71
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/tsv/TSVRead.java
TSVRead.readTSV
public static void readTSV(Connection connection, String fileName, String tableReference) throws SQLException, FileNotFoundException, IOException { File file = URIUtilities.fileFromString(fileName); if (FileUtil.isFileImportable(file, "tsv")) { TSVDriverFunction tsvDriver = new TSVDriverFunction(); tsvDriver.importFile(connection, tableReference, file, new EmptyProgressVisitor()); } }
java
public static void readTSV(Connection connection, String fileName, String tableReference) throws SQLException, FileNotFoundException, IOException { File file = URIUtilities.fileFromString(fileName); if (FileUtil.isFileImportable(file, "tsv")) { TSVDriverFunction tsvDriver = new TSVDriverFunction(); tsvDriver.importFile(connection, tableReference, file, new EmptyProgressVisitor()); } }
[ "public", "static", "void", "readTSV", "(", "Connection", "connection", ",", "String", "fileName", ",", "String", "tableReference", ")", "throws", "SQLException", ",", "FileNotFoundException", ",", "IOException", "{", "File", "file", "=", "URIUtilities", ".", "fil...
Copy data from TSV File into a new table in specified connection. @param connection @param fileName @param tableReference @throws SQLException @throws FileNotFoundException @throws IOException
[ "Copy", "data", "from", "TSV", "File", "into", "a", "new", "table", "in", "specified", "connection", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/tsv/TSVRead.java#L60-L66
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/affine_transformations/ST_Translate.java
ST_Translate.translate
public static Geometry translate(Geometry geom, double x, double y) { if (geom == null) { return null; } final CoordinateSequenceDimensionFilter filter = new CoordinateSequenceDimensionFilter(); geom.apply(filter); checkMixed(filter); return AffineTransformation.translationInstance(x, y).transform(geom); }
java
public static Geometry translate(Geometry geom, double x, double y) { if (geom == null) { return null; } final CoordinateSequenceDimensionFilter filter = new CoordinateSequenceDimensionFilter(); geom.apply(filter); checkMixed(filter); return AffineTransformation.translationInstance(x, y).transform(geom); }
[ "public", "static", "Geometry", "translate", "(", "Geometry", "geom", ",", "double", "x", ",", "double", "y", ")", "{", "if", "(", "geom", "==", "null", ")", "{", "return", "null", ";", "}", "final", "CoordinateSequenceDimensionFilter", "filter", "=", "new...
Translates a geometry using X and Y offsets. @param geom Geometry @param x X @param y Y @return Translated geometry
[ "Translates", "a", "geometry", "using", "X", "and", "Y", "offsets", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/affine_transformations/ST_Translate.java#L57-L66
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/affine_transformations/ST_Translate.java
ST_Translate.translate
public static Geometry translate(Geometry geom, double x, double y, double z) { if (geom == null) { return null; } final CoordinateSequenceDimensionFilter filter = new CoordinateSequenceDimensionFilter(); geom.apply(filter); checkMixed(filter); // For all 2D geometries, we only translate by (x, y). if (filter.is2D()) { return AffineTransformation.translationInstance(x, y).transform(geom); } else { final Geometry clone = geom.copy(); clone.apply(new ZAffineTransformation(x, y, z)); return clone; } }
java
public static Geometry translate(Geometry geom, double x, double y, double z) { if (geom == null) { return null; } final CoordinateSequenceDimensionFilter filter = new CoordinateSequenceDimensionFilter(); geom.apply(filter); checkMixed(filter); // For all 2D geometries, we only translate by (x, y). if (filter.is2D()) { return AffineTransformation.translationInstance(x, y).transform(geom); } else { final Geometry clone = geom.copy(); clone.apply(new ZAffineTransformation(x, y, z)); return clone; } }
[ "public", "static", "Geometry", "translate", "(", "Geometry", "geom", ",", "double", "x", ",", "double", "y", ",", "double", "z", ")", "{", "if", "(", "geom", "==", "null", ")", "{", "return", "null", ";", "}", "final", "CoordinateSequenceDimensionFilter",...
Translates a geometry using X, Y and Z offsets. @param geom Geometry @param x X @param y Y @param z Z @return Translated geometry
[ "Translates", "a", "geometry", "using", "X", "Y", "and", "Z", "offsets", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/affine_transformations/ST_Translate.java#L77-L93
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromWKB.java
ST_GeomFromWKB.toGeometry
public static Geometry toGeometry(byte[] bytes, int srid) throws SQLException{ if(bytes==null) { return null; } WKBReader wkbReader = new WKBReader(); try { Geometry geometry = wkbReader.read(bytes); geometry.setSRID(srid); return geometry; } catch (ParseException ex) { throw new SQLException("Cannot parse the input bytes",ex); } }
java
public static Geometry toGeometry(byte[] bytes, int srid) throws SQLException{ if(bytes==null) { return null; } WKBReader wkbReader = new WKBReader(); try { Geometry geometry = wkbReader.read(bytes); geometry.setSRID(srid); return geometry; } catch (ParseException ex) { throw new SQLException("Cannot parse the input bytes",ex); } }
[ "public", "static", "Geometry", "toGeometry", "(", "byte", "[", "]", "bytes", ",", "int", "srid", ")", "throws", "SQLException", "{", "if", "(", "bytes", "==", "null", ")", "{", "return", "null", ";", "}", "WKBReader", "wkbReader", "=", "new", "WKBReader...
Convert a WKB representation to a geometry @param bytes the input WKB object @param srid the input SRID @return @throws SQLException
[ "Convert", "a", "WKB", "representation", "to", "a", "geometry" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromWKB.java#L54-L66
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/distance/ST_MaxDistance.java
ST_MaxDistance.maxDistance
public static Double maxDistance(Geometry geomA, Geometry geomB) { return new MaxDistanceOp(geomA, geomB).getDistance(); }
java
public static Double maxDistance(Geometry geomA, Geometry geomB) { return new MaxDistanceOp(geomA, geomB).getDistance(); }
[ "public", "static", "Double", "maxDistance", "(", "Geometry", "geomA", ",", "Geometry", "geomB", ")", "{", "return", "new", "MaxDistanceOp", "(", "geomA", ",", "geomB", ")", ".", "getDistance", "(", ")", ";", "}" ]
Return the maximum distance @param geomA @param geomB @return
[ "Return", "the", "maximum", "distance" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/distance/ST_MaxDistance.java#L52-L54
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParser.java
AbstractGpxParser.characters
@Override public void characters(char[] ch, int start, int length) throws SAXException { contentBuffer.append(String.copyValueOf(ch, start, length)); }
java
@Override public void characters(char[] ch, int start, int length) throws SAXException { contentBuffer.append(String.copyValueOf(ch, start, length)); }
[ "@", "Override", "public", "void", "characters", "(", "char", "[", "]", "ch", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "contentBuffer", ".", "append", "(", "String", ".", "copyValueOf", "(", "ch", ",", "start", ",", ...
Fires one or more times for each text node encountered. It saves text informations in contentBuffer. @param ch The characters from the XML document @param start The start position in the array @param length The number of characters to read from the array @throws SAXException Any SAX exception, possibly wrapping another exception
[ "Fires", "one", "or", "more", "times", "for", "each", "text", "node", "encountered", ".", "It", "saves", "text", "informations", "in", "contentBuffer", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParser.java#L69-L72
train
orbisgis/h2gis
h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java
TableLocation.quoteIdentifier
public static String quoteIdentifier(String identifier, boolean isH2DataBase) { if((isH2DataBase && (Constants.H2_RESERVED_WORDS.contains(identifier.toUpperCase()) || !H2_SPECIAL_NAME_PATTERN.matcher(identifier).find())) || (!isH2DataBase && (Constants.POSTGIS_RESERVED_WORDS.contains(identifier.toUpperCase()) || !POSTGRE_SPECIAL_NAME_PATTERN.matcher(identifier).find()))) { return quoteIdentifier(identifier); } else { return identifier; } }
java
public static String quoteIdentifier(String identifier, boolean isH2DataBase) { if((isH2DataBase && (Constants.H2_RESERVED_WORDS.contains(identifier.toUpperCase()) || !H2_SPECIAL_NAME_PATTERN.matcher(identifier).find())) || (!isH2DataBase && (Constants.POSTGIS_RESERVED_WORDS.contains(identifier.toUpperCase()) || !POSTGRE_SPECIAL_NAME_PATTERN.matcher(identifier).find()))) { return quoteIdentifier(identifier); } else { return identifier; } }
[ "public", "static", "String", "quoteIdentifier", "(", "String", "identifier", ",", "boolean", "isH2DataBase", ")", "{", "if", "(", "(", "isH2DataBase", "&&", "(", "Constants", ".", "H2_RESERVED_WORDS", ".", "contains", "(", "identifier", ".", "toUpperCase", "(",...
Quote identifier only if necessary. Require database knowledge. @param identifier Catalog,Schema,Table or Field name @param isH2DataBase True if the quote is for H2, false if for POSTGRE @return Quoted Identifier
[ "Quote", "identifier", "only", "if", "necessary", ".", "Require", "database", "knowledge", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java#L96-L105
train
orbisgis/h2gis
h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java
TableLocation.parse
public static TableLocation parse(String concatenatedTableLocation, Boolean isH2Database) { List<String> parts = new LinkedList<String>(); String catalog,schema,table; catalog = table = schema = ""; StringTokenizer st = new StringTokenizer(concatenatedTableLocation, ".`\"", true); boolean openQuote = false; StringBuilder sb = new StringBuilder(); while(st.hasMoreTokens()) { String token = st.nextToken(); if(token.equals("`") || token.equals("\"")) { openQuote = !openQuote; } else if(token.equals(".")) { if(openQuote) { // Still in part sb.append(token); } else { // end of part parts.add(sb.toString()); sb = new StringBuilder(); } } else { if(!openQuote && isH2Database != null) { token = capsIdentifier(token, isH2Database); } sb.append(token); } } if(sb.length() != 0) { parts.add(sb.toString()); } String[] values = parts.toArray(new String[0]); switch (values.length) { case 1: table = values[0].trim(); break; case 2: schema = values[0].trim(); table = values[1].trim(); break; case 3: catalog = values[0].trim(); schema = values[1].trim(); table = values[2].trim(); } return new TableLocation(catalog,schema,table); }
java
public static TableLocation parse(String concatenatedTableLocation, Boolean isH2Database) { List<String> parts = new LinkedList<String>(); String catalog,schema,table; catalog = table = schema = ""; StringTokenizer st = new StringTokenizer(concatenatedTableLocation, ".`\"", true); boolean openQuote = false; StringBuilder sb = new StringBuilder(); while(st.hasMoreTokens()) { String token = st.nextToken(); if(token.equals("`") || token.equals("\"")) { openQuote = !openQuote; } else if(token.equals(".")) { if(openQuote) { // Still in part sb.append(token); } else { // end of part parts.add(sb.toString()); sb = new StringBuilder(); } } else { if(!openQuote && isH2Database != null) { token = capsIdentifier(token, isH2Database); } sb.append(token); } } if(sb.length() != 0) { parts.add(sb.toString()); } String[] values = parts.toArray(new String[0]); switch (values.length) { case 1: table = values[0].trim(); break; case 2: schema = values[0].trim(); table = values[1].trim(); break; case 3: catalog = values[0].trim(); schema = values[1].trim(); table = values[2].trim(); } return new TableLocation(catalog,schema,table); }
[ "public", "static", "TableLocation", "parse", "(", "String", "concatenatedTableLocation", ",", "Boolean", "isH2Database", ")", "{", "List", "<", "String", ">", "parts", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "String", "catalog", ",", "s...
Convert catalog.schema.table, schema.table or table into a TableLocation instance. Non-specified schema or catalogs are converted to the empty string. @param concatenatedTableLocation Table location [[Catalog.]Schema.]Table @param isH2Database True if H2, False if PostGreSQL, null if unknown @return Java beans for table location
[ "Convert", "catalog", ".", "schema", ".", "table", "schema", ".", "table", "or", "table", "into", "a", "TableLocation", "instance", ".", "Non", "-", "specified", "schema", "or", "catalogs", "are", "converted", "to", "the", "empty", "string", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java#L179-L224
train
orbisgis/h2gis
h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java
TableLocation.capsIdentifier
public static String capsIdentifier(String identifier, Boolean isH2Database) { if(isH2Database != null) { if(isH2Database) { return identifier.toUpperCase(); } else { return identifier.toLowerCase(); } } else { return identifier; } }
java
public static String capsIdentifier(String identifier, Boolean isH2Database) { if(isH2Database != null) { if(isH2Database) { return identifier.toUpperCase(); } else { return identifier.toLowerCase(); } } else { return identifier; } }
[ "public", "static", "String", "capsIdentifier", "(", "String", "identifier", ",", "Boolean", "isH2Database", ")", "{", "if", "(", "isH2Database", "!=", "null", ")", "{", "if", "(", "isH2Database", ")", "{", "return", "identifier", ".", "toUpperCase", "(", ")...
Change case of parameters to make it more user-friendly. @param identifier Table, Catalog, Schema, or column name @param isH2Database True if H2, False if PostGreSQL, null if unknown @return Upper or lower case version of identifier
[ "Change", "case", "of", "parameters", "to", "make", "it", "more", "user", "-", "friendly", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java#L233-L243
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.decompose
private static void decompose(Geometry geometry, Collection<Geometry> list) { for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry component = geometry.getGeometryN(i); if (component instanceof GeometryCollection) { decompose(component, list); } else { list.add(component); } } }
java
private static void decompose(Geometry geometry, Collection<Geometry> list) { for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry component = geometry.getGeometryN(i); if (component instanceof GeometryCollection) { decompose(component, list); } else { list.add(component); } } }
[ "private", "static", "void", "decompose", "(", "Geometry", "geometry", ",", "Collection", "<", "Geometry", ">", "list", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "geometry", ".", "getNumGeometries", "(", ")", ";", "i", "++", ")", "{"...
Decompose a geometry recursively into simple components. @param geometry input geometry @param list a list of simple components (Point, LineString or Polygon)
[ "Decompose", "a", "geometry", "recursively", "into", "simple", "components", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L98-L107
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.removeLowerDimension
private void removeLowerDimension(Geometry geometry, List<Geometry> result, int dimension) { for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); if (g instanceof GeometryCollection) { removeLowerDimension(g, result, dimension); } else if (g.getDimension() >= dimension) { result.add(g); } } }
java
private void removeLowerDimension(Geometry geometry, List<Geometry> result, int dimension) { for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); if (g instanceof GeometryCollection) { removeLowerDimension(g, result, dimension); } else if (g.getDimension() >= dimension) { result.add(g); } } }
[ "private", "void", "removeLowerDimension", "(", "Geometry", "geometry", ",", "List", "<", "Geometry", ">", "result", ",", "int", "dimension", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "geometry", ".", "getNumGeometries", "(", ")", ";", ...
Reursively remove geometries with a dimension less than dimension parameter
[ "Reursively", "remove", "geometries", "with", "a", "dimension", "less", "than", "dimension", "parameter" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L237-L246
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.unionAdjacentPolygons
private Collection<Geometry> unionAdjacentPolygons(Collection<Geometry> list) { UnaryUnionOp op = new UnaryUnionOp(list); Geometry result = op.union(); if (result.getNumGeometries() < list.size()) { list.clear(); for (int i = 0; i < result.getNumGeometries(); i++) { list.add(result.getGeometryN(i)); } } return list; }
java
private Collection<Geometry> unionAdjacentPolygons(Collection<Geometry> list) { UnaryUnionOp op = new UnaryUnionOp(list); Geometry result = op.union(); if (result.getNumGeometries() < list.size()) { list.clear(); for (int i = 0; i < result.getNumGeometries(); i++) { list.add(result.getGeometryN(i)); } } return list; }
[ "private", "Collection", "<", "Geometry", ">", "unionAdjacentPolygons", "(", "Collection", "<", "Geometry", ">", "list", ")", "{", "UnaryUnionOp", "op", "=", "new", "UnaryUnionOp", "(", "list", ")", ";", "Geometry", "result", "=", "op", ".", "union", "(", ...
Union adjacent polygons to make an invalid MultiPolygon valid
[ "Union", "adjacent", "polygons", "to", "make", "an", "invalid", "MultiPolygon", "valid" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L249-L259
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.makePointValid
private Point makePointValid(Point point) { CoordinateSequence sequence = point.getCoordinateSequence(); GeometryFactory factory = point.getFactory(); CoordinateSequenceFactory csFactory = factory.getCoordinateSequenceFactory(); if (sequence.size() == 0) { return point; } else if (Double.isNaN(sequence.getOrdinate(0, 0)) || Double.isNaN(sequence.getOrdinate(0, 1))) { return factory.createPoint(csFactory.create(0, sequence.getDimension())); } else if (sequence.size() == 1) { return point; } else { throw new RuntimeException("JTS cannot create a point from a CoordinateSequence containing several points"); } }
java
private Point makePointValid(Point point) { CoordinateSequence sequence = point.getCoordinateSequence(); GeometryFactory factory = point.getFactory(); CoordinateSequenceFactory csFactory = factory.getCoordinateSequenceFactory(); if (sequence.size() == 0) { return point; } else if (Double.isNaN(sequence.getOrdinate(0, 0)) || Double.isNaN(sequence.getOrdinate(0, 1))) { return factory.createPoint(csFactory.create(0, sequence.getDimension())); } else if (sequence.size() == 1) { return point; } else { throw new RuntimeException("JTS cannot create a point from a CoordinateSequence containing several points"); } }
[ "private", "Point", "makePointValid", "(", "Point", "point", ")", "{", "CoordinateSequence", "sequence", "=", "point", ".", "getCoordinateSequence", "(", ")", ";", "GeometryFactory", "factory", "=", "point", ".", "getFactory", "(", ")", ";", "CoordinateSequenceFac...
If X or Y is null, return an empty Point
[ "If", "X", "or", "Y", "is", "null", "return", "an", "empty", "Point" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L262-L275
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.makeSequenceValid
private static CoordinateSequence makeSequenceValid(CoordinateSequence sequence, boolean preserveDuplicateCoord, boolean close) { int dim = sequence.getDimension(); // we add 1 to the sequence size for the case where we have to close the linear ring double[] array = new double[(sequence.size() + 1) * sequence.getDimension()]; boolean modified = false; int count = 0; // Iterate through coordinates, skip points with x=NaN, y=NaN or duplicate for (int i = 0; i < sequence.size(); i++) { if (Double.isNaN(sequence.getOrdinate(i, 0)) || Double.isNaN(sequence.getOrdinate(i, 1))) { modified = true; continue; } if (!preserveDuplicateCoord && count > 0 && sequence.getCoordinate(i).equals(sequence.getCoordinate(i - 1))) { modified = true; continue; } for (int j = 0; j < dim; j++) { array[count * dim + j] = sequence.getOrdinate(i, j); if (j == dim - 1) { count++; } } } // Close the sequence if it is not closed and there is already 3 distinct coordinates if (close && count > 2 && (array[0] != array[(count - 1) * dim] || array[1] != array[(count - 1) * dim + 1])) { System.arraycopy(array, 0, array, count * dim, dim); modified = true; count++; } // Close z, m dimension if needed if (close && count > 3 && dim > 2) { for (int d = 2; d < dim; d++) { if (array[(count - 1) * dim + d] != array[d]) { modified = true; } array[(count - 1) * dim + d] = array[d]; } } if (modified) { double[] shrinkedArray = new double[count * dim]; System.arraycopy(array, 0, shrinkedArray, 0, count * dim); return PackedCoordinateSequenceFactory.DOUBLE_FACTORY.create(shrinkedArray, dim); } else { return sequence; } }
java
private static CoordinateSequence makeSequenceValid(CoordinateSequence sequence, boolean preserveDuplicateCoord, boolean close) { int dim = sequence.getDimension(); // we add 1 to the sequence size for the case where we have to close the linear ring double[] array = new double[(sequence.size() + 1) * sequence.getDimension()]; boolean modified = false; int count = 0; // Iterate through coordinates, skip points with x=NaN, y=NaN or duplicate for (int i = 0; i < sequence.size(); i++) { if (Double.isNaN(sequence.getOrdinate(i, 0)) || Double.isNaN(sequence.getOrdinate(i, 1))) { modified = true; continue; } if (!preserveDuplicateCoord && count > 0 && sequence.getCoordinate(i).equals(sequence.getCoordinate(i - 1))) { modified = true; continue; } for (int j = 0; j < dim; j++) { array[count * dim + j] = sequence.getOrdinate(i, j); if (j == dim - 1) { count++; } } } // Close the sequence if it is not closed and there is already 3 distinct coordinates if (close && count > 2 && (array[0] != array[(count - 1) * dim] || array[1] != array[(count - 1) * dim + 1])) { System.arraycopy(array, 0, array, count * dim, dim); modified = true; count++; } // Close z, m dimension if needed if (close && count > 3 && dim > 2) { for (int d = 2; d < dim; d++) { if (array[(count - 1) * dim + d] != array[d]) { modified = true; } array[(count - 1) * dim + d] = array[d]; } } if (modified) { double[] shrinkedArray = new double[count * dim]; System.arraycopy(array, 0, shrinkedArray, 0, count * dim); return PackedCoordinateSequenceFactory.DOUBLE_FACTORY.create(shrinkedArray, dim); } else { return sequence; } }
[ "private", "static", "CoordinateSequence", "makeSequenceValid", "(", "CoordinateSequence", "sequence", ",", "boolean", "preserveDuplicateCoord", ",", "boolean", "close", ")", "{", "int", "dim", "=", "sequence", ".", "getDimension", "(", ")", ";", "// we add 1 to the s...
Returns a coordinateSequence free of Coordinates with X or Y NaN value, and if desired, free of duplicated coordinates. makeSequenceValid keeps the original dimension of input sequence. @param sequence input sequence of coordinates @param preserveDuplicateCoord if duplicate coordinates must be preserved @param close if the sequence must be closed @return a new CoordinateSequence with valid XY values
[ "Returns", "a", "coordinateSequence", "free", "of", "Coordinates", "with", "X", "or", "Y", "NaN", "value", "and", "if", "desired", "free", "of", "duplicated", "coordinates", ".", "makeSequenceValid", "keeps", "the", "original", "dimension", "of", "input", "seque...
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L287-L333
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.getSegments
private Set<LineString> getSegments(Collection<LineString> lines) { Set<LineString> set = new HashSet<>(); for (LineString line : lines) { Coordinate[] cc = line.getCoordinates(); for (int i = 1; i < cc.length; i++) { if (!cc[i - 1].equals(cc[i])) { LineString segment = line.getFactory().createLineString( new Coordinate[]{new Coordinate(cc[i - 1]), new Coordinate(cc[i])}); set.add(segment); } } } return set; }
java
private Set<LineString> getSegments(Collection<LineString> lines) { Set<LineString> set = new HashSet<>(); for (LineString line : lines) { Coordinate[] cc = line.getCoordinates(); for (int i = 1; i < cc.length; i++) { if (!cc[i - 1].equals(cc[i])) { LineString segment = line.getFactory().createLineString( new Coordinate[]{new Coordinate(cc[i - 1]), new Coordinate(cc[i])}); set.add(segment); } } } return set; }
[ "private", "Set", "<", "LineString", ">", "getSegments", "(", "Collection", "<", "LineString", ">", "lines", ")", "{", "Set", "<", "LineString", ">", "set", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "LineString", "line", ":", "lines", ")"...
Return a set of segments from a linestring @param lines @return
[ "Return", "a", "set", "of", "segments", "from", "a", "linestring" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L551-L564
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.restoreDim4
private Collection<Geometry> restoreDim4(Collection<Geometry> geoms, Map<Coordinate, Double> map) { GeometryFactory factory = new GeometryFactory( new PackedCoordinateSequenceFactory(PackedCoordinateSequenceFactory.DOUBLE, 4)); Collection<Geometry> result = new ArrayList<>(); for (Geometry geom : geoms) { if (geom instanceof Point) { result.add(factory.createPoint(restoreDim4( ((Point) geom).getCoordinateSequence(), map))); } else if (geom instanceof LineString) { result.add(factory.createLineString(restoreDim4( ((LineString) geom).getCoordinateSequence(), map))); } else if (geom instanceof Polygon) { LinearRing outer = factory.createLinearRing(restoreDim4( ((Polygon) geom).getExteriorRing().getCoordinateSequence(), map)); LinearRing[] inner = new LinearRing[((Polygon) geom).getNumInteriorRing()]; for (int i = 0; i < ((Polygon) geom).getNumInteriorRing(); i++) { inner[i] = factory.createLinearRing(restoreDim4( ((Polygon) geom).getInteriorRingN(i).getCoordinateSequence(), map)); } result.add(factory.createPolygon(outer, inner)); } else { for (int i = 0; i < geom.getNumGeometries(); i++) { result.addAll(restoreDim4(Collections.singleton(geom.getGeometryN(i)), map)); } } } return result; }
java
private Collection<Geometry> restoreDim4(Collection<Geometry> geoms, Map<Coordinate, Double> map) { GeometryFactory factory = new GeometryFactory( new PackedCoordinateSequenceFactory(PackedCoordinateSequenceFactory.DOUBLE, 4)); Collection<Geometry> result = new ArrayList<>(); for (Geometry geom : geoms) { if (geom instanceof Point) { result.add(factory.createPoint(restoreDim4( ((Point) geom).getCoordinateSequence(), map))); } else if (geom instanceof LineString) { result.add(factory.createLineString(restoreDim4( ((LineString) geom).getCoordinateSequence(), map))); } else if (geom instanceof Polygon) { LinearRing outer = factory.createLinearRing(restoreDim4( ((Polygon) geom).getExteriorRing().getCoordinateSequence(), map)); LinearRing[] inner = new LinearRing[((Polygon) geom).getNumInteriorRing()]; for (int i = 0; i < ((Polygon) geom).getNumInteriorRing(); i++) { inner[i] = factory.createLinearRing(restoreDim4( ((Polygon) geom).getInteriorRingN(i).getCoordinateSequence(), map)); } result.add(factory.createPolygon(outer, inner)); } else { for (int i = 0; i < geom.getNumGeometries(); i++) { result.addAll(restoreDim4(Collections.singleton(geom.getGeometryN(i)), map)); } } } return result; }
[ "private", "Collection", "<", "Geometry", ">", "restoreDim4", "(", "Collection", "<", "Geometry", ">", "geoms", ",", "Map", "<", "Coordinate", ",", "Double", ">", "map", ")", "{", "GeometryFactory", "factory", "=", "new", "GeometryFactory", "(", "new", "Pack...
Use ring to restore M values on geoms
[ "Use", "ring", "to", "restore", "M", "values", "on", "geoms" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L567-L594
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java
MakeValidOp.restoreDim4
private CoordinateSequence restoreDim4(CoordinateSequence cs, Map<Coordinate, Double> map) { CoordinateSequence seq = new PackedCoordinateSequenceFactory(DOUBLE, 4).create(cs.size(), 4); for (int i = 0; i < cs.size(); i++) { seq.setOrdinate(i, 0, cs.getOrdinate(i, 0)); seq.setOrdinate(i, 1, cs.getOrdinate(i, 1)); seq.setOrdinate(i, 2, cs.getOrdinate(i, 2)); Double d = map.get(cs.getCoordinate(i)); seq.setOrdinate(i, 3, d == null ? Double.NaN : d); } return seq; }
java
private CoordinateSequence restoreDim4(CoordinateSequence cs, Map<Coordinate, Double> map) { CoordinateSequence seq = new PackedCoordinateSequenceFactory(DOUBLE, 4).create(cs.size(), 4); for (int i = 0; i < cs.size(); i++) { seq.setOrdinate(i, 0, cs.getOrdinate(i, 0)); seq.setOrdinate(i, 1, cs.getOrdinate(i, 1)); seq.setOrdinate(i, 2, cs.getOrdinate(i, 2)); Double d = map.get(cs.getCoordinate(i)); seq.setOrdinate(i, 3, d == null ? Double.NaN : d); } return seq; }
[ "private", "CoordinateSequence", "restoreDim4", "(", "CoordinateSequence", "cs", ",", "Map", "<", "Coordinate", ",", "Double", ">", "map", ")", "{", "CoordinateSequence", "seq", "=", "new", "PackedCoordinateSequenceFactory", "(", "DOUBLE", ",", "4", ")", ".", "c...
Use map to restore M values on the coordinate array
[ "Use", "map", "to", "restore", "M", "values", "on", "the", "coordinate", "array" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L624-L634
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/GPXTablesFactory.java
GPXTablesFactory.createTrackTable
public static PreparedStatement createTrackTable(Connection connection, String trackTableName,boolean isH2) throws SQLException { try (Statement stmt = connection.createStatement()) { StringBuilder sb = new StringBuilder("CREATE TABLE "); sb.append(trackTableName).append(" ("); if (isH2) { sb.append("the_geom MULTILINESTRING CHECK ST_SRID(THE_GEOM) = 4326,"); } else { sb.append("the_geom GEOMETRY(MULTILINESTRING, 4326),"); } sb.append(" id INT,"); sb.append(GPXTags.NAME.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.CMT.toLowerCase()).append(" TEXT,"); sb.append("description").append(" TEXT,"); sb.append(GPXTags.SRC.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.HREF.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.HREFTITLE.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.NUMBER.toLowerCase()).append(" INT,"); sb.append(GPXTags.TYPE.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.EXTENSIONS.toLowerCase()).append(" TEXT);"); stmt.execute(sb.toString()); } //We return the preparedstatement of the route table StringBuilder insert = new StringBuilder("INSERT INTO ").append(trackTableName).append(" VALUES ( ?"); for (int i = 1; i < GpxMetadata.RTEFIELDCOUNT; i++) { insert.append(",?"); } insert.append(");"); return connection.prepareStatement(insert.toString()); }
java
public static PreparedStatement createTrackTable(Connection connection, String trackTableName,boolean isH2) throws SQLException { try (Statement stmt = connection.createStatement()) { StringBuilder sb = new StringBuilder("CREATE TABLE "); sb.append(trackTableName).append(" ("); if (isH2) { sb.append("the_geom MULTILINESTRING CHECK ST_SRID(THE_GEOM) = 4326,"); } else { sb.append("the_geom GEOMETRY(MULTILINESTRING, 4326),"); } sb.append(" id INT,"); sb.append(GPXTags.NAME.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.CMT.toLowerCase()).append(" TEXT,"); sb.append("description").append(" TEXT,"); sb.append(GPXTags.SRC.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.HREF.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.HREFTITLE.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.NUMBER.toLowerCase()).append(" INT,"); sb.append(GPXTags.TYPE.toLowerCase()).append(" TEXT,"); sb.append(GPXTags.EXTENSIONS.toLowerCase()).append(" TEXT);"); stmt.execute(sb.toString()); } //We return the preparedstatement of the route table StringBuilder insert = new StringBuilder("INSERT INTO ").append(trackTableName).append(" VALUES ( ?"); for (int i = 1; i < GpxMetadata.RTEFIELDCOUNT; i++) { insert.append(",?"); } insert.append(");"); return connection.prepareStatement(insert.toString()); }
[ "public", "static", "PreparedStatement", "createTrackTable", "(", "Connection", "connection", ",", "String", "trackTableName", ",", "boolean", "isH2", ")", "throws", "SQLException", "{", "try", "(", "Statement", "stmt", "=", "connection", ".", "createStatement", "("...
Creat the track table @param connection @param trackTableName @param isH2 set true if it's an H2 database @return @throws SQLException
[ "Creat", "the", "track", "table" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/GPXTablesFactory.java#L204-L233
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/GPXTablesFactory.java
GPXTablesFactory.createTrackSegmentsTable
public static PreparedStatement createTrackSegmentsTable(Connection connection, String trackSegementsTableName,boolean isH2) throws SQLException { try (Statement stmt = connection.createStatement()) { StringBuilder sb = new StringBuilder("CREATE TABLE "); sb.append(trackSegementsTableName).append(" ("); if (isH2) { sb.append("the_geom LINESTRING CHECK ST_SRID(THE_GEOM) = 4326,"); } else { sb.append("the_geom GEOMETRY(LINESTRING, 4326),"); } sb.append(" id INT,"); sb.append(GPXTags.EXTENSIONS).append(" TEXT,"); sb.append("id_track INT);"); stmt.execute(sb.toString()); } //We return the preparedstatement of the waypoints table StringBuilder insert = new StringBuilder("INSERT INTO ").append(trackSegementsTableName).append(" VALUES ( ?"); for (int i = 1; i < GpxMetadata.TRKSEGFIELDCOUNT; i++) { insert.append(",?"); } insert.append(");"); return connection.prepareStatement(insert.toString()); }
java
public static PreparedStatement createTrackSegmentsTable(Connection connection, String trackSegementsTableName,boolean isH2) throws SQLException { try (Statement stmt = connection.createStatement()) { StringBuilder sb = new StringBuilder("CREATE TABLE "); sb.append(trackSegementsTableName).append(" ("); if (isH2) { sb.append("the_geom LINESTRING CHECK ST_SRID(THE_GEOM) = 4326,"); } else { sb.append("the_geom GEOMETRY(LINESTRING, 4326),"); } sb.append(" id INT,"); sb.append(GPXTags.EXTENSIONS).append(" TEXT,"); sb.append("id_track INT);"); stmt.execute(sb.toString()); } //We return the preparedstatement of the waypoints table StringBuilder insert = new StringBuilder("INSERT INTO ").append(trackSegementsTableName).append(" VALUES ( ?"); for (int i = 1; i < GpxMetadata.TRKSEGFIELDCOUNT; i++) { insert.append(",?"); } insert.append(");"); return connection.prepareStatement(insert.toString()); }
[ "public", "static", "PreparedStatement", "createTrackSegmentsTable", "(", "Connection", "connection", ",", "String", "trackSegementsTableName", ",", "boolean", "isH2", ")", "throws", "SQLException", "{", "try", "(", "Statement", "stmt", "=", "connection", ".", "create...
Create the track segments table to store the segments of a track @param connection @param trackSegementsTableName @param isH2 set true if it's an H2 database @return @throws SQLException
[ "Create", "the", "track", "segments", "table", "to", "store", "the", "segments", "of", "a", "track" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/GPXTablesFactory.java#L244-L266
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/GPXTablesFactory.java
GPXTablesFactory.dropOSMTables
public static void dropOSMTables(Connection connection, boolean isH2, String tablePrefix) throws SQLException { TableLocation requestedTable = TableLocation.parse(tablePrefix, isH2); String gpxTableName = requestedTable.getTable(); String[] gpxTables = new String[]{WAYPOINT,ROUTE,ROUTEPOINT, TRACK, TRACKPOINT, TRACKSEGMENT}; StringBuilder sb = new StringBuilder("drop table if exists "); String gpxTableSuffix = gpxTables[0]; String gpxTable = TableUtilities.caseIdentifier(requestedTable, gpxTableName + gpxTableSuffix, isH2); sb.append(gpxTable); for (int i = 1; i < gpxTables.length; i++) { gpxTableSuffix = gpxTables[i]; gpxTable = TableUtilities.caseIdentifier(requestedTable, gpxTableName + gpxTableSuffix, isH2); sb.append(",").append(gpxTable); } try (Statement stmt = connection.createStatement()) { stmt.execute(sb.toString()); } }
java
public static void dropOSMTables(Connection connection, boolean isH2, String tablePrefix) throws SQLException { TableLocation requestedTable = TableLocation.parse(tablePrefix, isH2); String gpxTableName = requestedTable.getTable(); String[] gpxTables = new String[]{WAYPOINT,ROUTE,ROUTEPOINT, TRACK, TRACKPOINT, TRACKSEGMENT}; StringBuilder sb = new StringBuilder("drop table if exists "); String gpxTableSuffix = gpxTables[0]; String gpxTable = TableUtilities.caseIdentifier(requestedTable, gpxTableName + gpxTableSuffix, isH2); sb.append(gpxTable); for (int i = 1; i < gpxTables.length; i++) { gpxTableSuffix = gpxTables[i]; gpxTable = TableUtilities.caseIdentifier(requestedTable, gpxTableName + gpxTableSuffix, isH2); sb.append(",").append(gpxTable); } try (Statement stmt = connection.createStatement()) { stmt.execute(sb.toString()); } }
[ "public", "static", "void", "dropOSMTables", "(", "Connection", "connection", ",", "boolean", "isH2", ",", "String", "tablePrefix", ")", "throws", "SQLException", "{", "TableLocation", "requestedTable", "=", "TableLocation", ".", "parse", "(", "tablePrefix", ",", ...
Drop the existing GPX tables used to store the imported OSM GPX @param connection @param isH2 @param tablePrefix @throws SQLException
[ "Drop", "the", "existing", "GPX", "tables", "used", "to", "store", "the", "imported", "OSM", "GPX" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/GPXTablesFactory.java#L331-L347
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/kml/AltitudeMode.java
AltitudeMode.append
public static void append(int altitudeMode, StringBuilder sb) { switch (altitudeMode) { case KML_CLAMPTOGROUND: sb.append("<kml:altitudeMode>clampToGround</kml:altitudeMode>"); return; case KML_RELATIVETOGROUND: sb.append("<kml:altitudeMode>relativeToGround</kml:altitudeMode>"); return; case KML_ABSOLUTE: sb.append("<kml:altitudeMode>absolute</kml:altitudeMode>"); return; case GX_CLAMPTOSEAFLOOR: sb.append("<gx:altitudeMode>clampToSeaFloor</gx:altitudeMode>"); return; case GX_RELATIVETOSEAFLOOR: sb.append("<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>"); return; case NONE: return; default: throw new IllegalArgumentException("Supported altitude modes are: \n" + " For KML profils: CLAMPTOGROUND = 1; RELATIVETOGROUND = 2; ABSOLUTE = 4;\n" + "For GX profils: CLAMPTOSEAFLOOR = 8; RELATIVETOSEAFLOOR = 16; \n" + " No altitude: NONE = 0"); } }
java
public static void append(int altitudeMode, StringBuilder sb) { switch (altitudeMode) { case KML_CLAMPTOGROUND: sb.append("<kml:altitudeMode>clampToGround</kml:altitudeMode>"); return; case KML_RELATIVETOGROUND: sb.append("<kml:altitudeMode>relativeToGround</kml:altitudeMode>"); return; case KML_ABSOLUTE: sb.append("<kml:altitudeMode>absolute</kml:altitudeMode>"); return; case GX_CLAMPTOSEAFLOOR: sb.append("<gx:altitudeMode>clampToSeaFloor</gx:altitudeMode>"); return; case GX_RELATIVETOSEAFLOOR: sb.append("<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>"); return; case NONE: return; default: throw new IllegalArgumentException("Supported altitude modes are: \n" + " For KML profils: CLAMPTOGROUND = 1; RELATIVETOGROUND = 2; ABSOLUTE = 4;\n" + "For GX profils: CLAMPTOSEAFLOOR = 8; RELATIVETOSEAFLOOR = 16; \n" + " No altitude: NONE = 0"); } }
[ "public", "static", "void", "append", "(", "int", "altitudeMode", ",", "StringBuilder", "sb", ")", "{", "switch", "(", "altitudeMode", ")", "{", "case", "KML_CLAMPTOGROUND", ":", "sb", ".", "append", "(", "\"<kml:altitudeMode>clampToGround</kml:altitudeMode>\"", ")"...
Generate a string value corresponding to the altitude mode. @param altitudeMode @param sb
[ "Generate", "a", "string", "value", "corresponding", "to", "the", "altitude", "mode", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/kml/AltitudeMode.java#L73-L98
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extrudePolygonAsGeometry
public static GeometryCollection extrudePolygonAsGeometry(Polygon polygon, double height){ GeometryFactory factory = polygon.getFactory(); Geometry[] geometries = new Geometry[3]; //Extract floor //We process the exterior ring final LineString shell = getClockWise(polygon.getExteriorRing()); ArrayList<Polygon> walls = new ArrayList<Polygon>(); for (int i = 1; i < shell.getNumPoints(); i++) { walls.add(extrudeEdge(shell.getCoordinateN(i - 1), shell.getCoordinateN(i), height, factory)); } final int nbOfHoles = polygon.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { final LineString hole = getCounterClockWise(polygon.getInteriorRingN(i)); for (int j = 1; j < hole.getNumPoints(); j++) { walls.add(extrudeEdge(hole.getCoordinateN(j - 1), hole.getCoordinateN(j), height, factory)); } holes[i] = factory.createLinearRing(hole.getCoordinateSequence()); } geometries[0]= factory.createPolygon(factory.createLinearRing(shell.getCoordinateSequence()), holes); geometries[1]= factory.createMultiPolygon(walls.toArray(new Polygon[0])); geometries[2]= extractRoof(polygon, height); return polygon.getFactory().createGeometryCollection(geometries); }
java
public static GeometryCollection extrudePolygonAsGeometry(Polygon polygon, double height){ GeometryFactory factory = polygon.getFactory(); Geometry[] geometries = new Geometry[3]; //Extract floor //We process the exterior ring final LineString shell = getClockWise(polygon.getExteriorRing()); ArrayList<Polygon> walls = new ArrayList<Polygon>(); for (int i = 1; i < shell.getNumPoints(); i++) { walls.add(extrudeEdge(shell.getCoordinateN(i - 1), shell.getCoordinateN(i), height, factory)); } final int nbOfHoles = polygon.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { final LineString hole = getCounterClockWise(polygon.getInteriorRingN(i)); for (int j = 1; j < hole.getNumPoints(); j++) { walls.add(extrudeEdge(hole.getCoordinateN(j - 1), hole.getCoordinateN(j), height, factory)); } holes[i] = factory.createLinearRing(hole.getCoordinateSequence()); } geometries[0]= factory.createPolygon(factory.createLinearRing(shell.getCoordinateSequence()), holes); geometries[1]= factory.createMultiPolygon(walls.toArray(new Polygon[0])); geometries[2]= extractRoof(polygon, height); return polygon.getFactory().createGeometryCollection(geometries); }
[ "public", "static", "GeometryCollection", "extrudePolygonAsGeometry", "(", "Polygon", "polygon", ",", "double", "height", ")", "{", "GeometryFactory", "factory", "=", "polygon", ".", "getFactory", "(", ")", ";", "Geometry", "[", "]", "geometries", "=", "new", "G...
Extrude the polygon as a collection of geometries The output geometryCollection contains the floor, the walls and the roof. @param polygon @param height @return
[ "Extrude", "the", "polygon", "as", "a", "collection", "of", "geometries", "The", "output", "geometryCollection", "contains", "the", "floor", "the", "walls", "and", "the", "roof", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L49-L75
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extrudeLineStringAsGeometry
public static GeometryCollection extrudeLineStringAsGeometry(LineString lineString, double height){ Geometry[] geometries = new Geometry[3]; GeometryFactory factory = lineString.getFactory(); //Extract the walls Coordinate[] coords = lineString.getCoordinates(); Polygon[] walls = new Polygon[coords.length - 1]; for (int i = 0; i < coords.length - 1; i++) { walls[i] = extrudeEdge(coords[i], coords[i + 1], height, factory); } lineString.apply(new TranslateCoordinateSequenceFilter(0)); geometries[0]= lineString; geometries[1]= factory.createMultiPolygon(walls); geometries[2]= extractRoof(lineString, height); return factory.createGeometryCollection(geometries); }
java
public static GeometryCollection extrudeLineStringAsGeometry(LineString lineString, double height){ Geometry[] geometries = new Geometry[3]; GeometryFactory factory = lineString.getFactory(); //Extract the walls Coordinate[] coords = lineString.getCoordinates(); Polygon[] walls = new Polygon[coords.length - 1]; for (int i = 0; i < coords.length - 1; i++) { walls[i] = extrudeEdge(coords[i], coords[i + 1], height, factory); } lineString.apply(new TranslateCoordinateSequenceFilter(0)); geometries[0]= lineString; geometries[1]= factory.createMultiPolygon(walls); geometries[2]= extractRoof(lineString, height); return factory.createGeometryCollection(geometries); }
[ "public", "static", "GeometryCollection", "extrudeLineStringAsGeometry", "(", "LineString", "lineString", ",", "double", "height", ")", "{", "Geometry", "[", "]", "geometries", "=", "new", "Geometry", "[", "3", "]", ";", "GeometryFactory", "factory", "=", "lineStr...
Extrude the linestring as a collection of geometries The output geometryCollection contains the floor, the walls and the roof. @param lineString @param height @return
[ "Extrude", "the", "linestring", "as", "a", "collection", "of", "geometries", "The", "output", "geometryCollection", "contains", "the", "floor", "the", "walls", "and", "the", "roof", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L84-L98
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extractRoof
public static Geometry extractRoof(LineString lineString, double height) { LineString result = (LineString)lineString.copy(); result.apply(new TranslateCoordinateSequenceFilter(height)); return result; }
java
public static Geometry extractRoof(LineString lineString, double height) { LineString result = (LineString)lineString.copy(); result.apply(new TranslateCoordinateSequenceFilter(height)); return result; }
[ "public", "static", "Geometry", "extractRoof", "(", "LineString", "lineString", ",", "double", "height", ")", "{", "LineString", "result", "=", "(", "LineString", ")", "lineString", ".", "copy", "(", ")", ";", "result", ".", "apply", "(", "new", "TranslateCo...
Extract the linestring "roof". @param lineString @param height @return
[ "Extract", "the", "linestring", "roof", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L107-L111
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extractWalls
public static MultiPolygon extractWalls(Polygon polygon, double height){ GeometryFactory factory = polygon.getFactory(); //We process the exterior ring final LineString shell = getClockWise(polygon.getExteriorRing()); ArrayList<Polygon> walls = new ArrayList<Polygon>(); for (int i = 1; i < shell.getNumPoints(); i++) { walls.add(extrudeEdge(shell.getCoordinateN(i - 1), shell.getCoordinateN(i), height, factory)); } // We create the walls for all holes int nbOfHoles = polygon.getNumInteriorRing(); for (int i = 0; i < nbOfHoles; i++) { final LineString hole = getCounterClockWise(polygon.getInteriorRingN(i)); for (int j = 1; j < hole.getNumPoints(); j++) { walls.add(extrudeEdge(hole.getCoordinateN(j - 1), hole.getCoordinateN(j), height, factory)); } } return polygon.getFactory().createMultiPolygon(walls.toArray(new Polygon[0])); }
java
public static MultiPolygon extractWalls(Polygon polygon, double height){ GeometryFactory factory = polygon.getFactory(); //We process the exterior ring final LineString shell = getClockWise(polygon.getExteriorRing()); ArrayList<Polygon> walls = new ArrayList<Polygon>(); for (int i = 1; i < shell.getNumPoints(); i++) { walls.add(extrudeEdge(shell.getCoordinateN(i - 1), shell.getCoordinateN(i), height, factory)); } // We create the walls for all holes int nbOfHoles = polygon.getNumInteriorRing(); for (int i = 0; i < nbOfHoles; i++) { final LineString hole = getCounterClockWise(polygon.getInteriorRingN(i)); for (int j = 1; j < hole.getNumPoints(); j++) { walls.add(extrudeEdge(hole.getCoordinateN(j - 1), hole.getCoordinateN(j), height, factory)); } } return polygon.getFactory().createMultiPolygon(walls.toArray(new Polygon[0])); }
[ "public", "static", "MultiPolygon", "extractWalls", "(", "Polygon", "polygon", ",", "double", "height", ")", "{", "GeometryFactory", "factory", "=", "polygon", ".", "getFactory", "(", ")", ";", "//We process the exterior ring ", "final", "LineString", "shell", "=", ...
Extract the walls from a polygon @param polygon @param height @return
[ "Extract", "the", "walls", "from", "a", "polygon" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L121-L141
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extractRoof
public static Polygon extractRoof(Polygon polygon, double height) { GeometryFactory factory = polygon.getFactory(); Polygon roofP = (Polygon)polygon.copy(); roofP.apply(new TranslateCoordinateSequenceFilter(height)); final LinearRing shell = factory.createLinearRing(getCounterClockWise(roofP.getExteriorRing()).getCoordinates()); final int nbOfHoles = roofP.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { holes[i] = factory.createLinearRing(getClockWise( roofP.getInteriorRingN(i)).getCoordinates()); } return factory.createPolygon(shell, holes); }
java
public static Polygon extractRoof(Polygon polygon, double height) { GeometryFactory factory = polygon.getFactory(); Polygon roofP = (Polygon)polygon.copy(); roofP.apply(new TranslateCoordinateSequenceFilter(height)); final LinearRing shell = factory.createLinearRing(getCounterClockWise(roofP.getExteriorRing()).getCoordinates()); final int nbOfHoles = roofP.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { holes[i] = factory.createLinearRing(getClockWise( roofP.getInteriorRingN(i)).getCoordinates()); } return factory.createPolygon(shell, holes); }
[ "public", "static", "Polygon", "extractRoof", "(", "Polygon", "polygon", ",", "double", "height", ")", "{", "GeometryFactory", "factory", "=", "polygon", ".", "getFactory", "(", ")", ";", "Polygon", "roofP", "=", "(", "Polygon", ")", "polygon", ".", "copy", ...
Extract the roof of a polygon @param polygon @param height @return
[ "Extract", "the", "roof", "of", "a", "polygon" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L150-L162
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extractWalls
public static MultiPolygon extractWalls(LineString lineString, double height) { GeometryFactory factory = lineString.getFactory(); //Extract the walls Coordinate[] coords = lineString.getCoordinates(); Polygon[] walls = new Polygon[coords.length - 1]; for (int i = 0; i < coords.length - 1; i++) { walls[i] = extrudeEdge(coords[i], coords[i + 1], height, factory); } return lineString.getFactory().createMultiPolygon(walls); }
java
public static MultiPolygon extractWalls(LineString lineString, double height) { GeometryFactory factory = lineString.getFactory(); //Extract the walls Coordinate[] coords = lineString.getCoordinates(); Polygon[] walls = new Polygon[coords.length - 1]; for (int i = 0; i < coords.length - 1; i++) { walls[i] = extrudeEdge(coords[i], coords[i + 1], height, factory); } return lineString.getFactory().createMultiPolygon(walls); }
[ "public", "static", "MultiPolygon", "extractWalls", "(", "LineString", "lineString", ",", "double", "height", ")", "{", "GeometryFactory", "factory", "=", "lineString", ".", "getFactory", "(", ")", ";", "//Extract the walls ", "Coordinate", "[", "]", "coords"...
Extrude the LineString as a set of walls. @param lineString @param height @return
[ "Extrude", "the", "LineString", "as", "a", "set", "of", "walls", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L170-L179
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.getClockWise
private static LineString getClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.CLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
java
private static LineString getClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.CLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
[ "private", "static", "LineString", "getClockWise", "(", "final", "LineString", "lineString", ")", "{", "final", "Coordinate", "c0", "=", "lineString", ".", "getCoordinateN", "(", "0", ")", ";", "final", "Coordinate", "c1", "=", "lineString", ".", "getCoordinateN...
Reverse the LineString to be oriented clockwise. All NaN z values are replaced by a zero value. @param lineString @return
[ "Reverse", "the", "LineString", "to", "be", "oriented", "clockwise", ".", "All", "NaN", "z", "values", "are", "replaced", "by", "a", "zero", "value", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L187-L197
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.getCounterClockWise
private static LineString getCounterClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.COUNTERCLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
java
private static LineString getCounterClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.COUNTERCLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
[ "private", "static", "LineString", "getCounterClockWise", "(", "final", "LineString", "lineString", ")", "{", "final", "Coordinate", "c0", "=", "lineString", ".", "getCoordinateN", "(", "0", ")", ";", "final", "Coordinate", "c1", "=", "lineString", ".", "getCoor...
Reverse the LineString to be oriented counter-clockwise. @param lineString @return
[ "Reverse", "the", "LineString", "to", "be", "oriented", "counter", "-", "clockwise", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L204-L214
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extractFloor
private static Polygon extractFloor(final Polygon polygon) { GeometryFactory factory = polygon.getFactory(); final LinearRing shell = factory.createLinearRing(getClockWise( polygon.getExteriorRing()).getCoordinates()); final int nbOfHoles = polygon.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { holes[i] = factory.createLinearRing(getCounterClockWise( polygon.getInteriorRingN(i)).getCoordinates()); } return factory.createPolygon(shell, holes); }
java
private static Polygon extractFloor(final Polygon polygon) { GeometryFactory factory = polygon.getFactory(); final LinearRing shell = factory.createLinearRing(getClockWise( polygon.getExteriorRing()).getCoordinates()); final int nbOfHoles = polygon.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { holes[i] = factory.createLinearRing(getCounterClockWise( polygon.getInteriorRingN(i)).getCoordinates()); } return factory.createPolygon(shell, holes); }
[ "private", "static", "Polygon", "extractFloor", "(", "final", "Polygon", "polygon", ")", "{", "GeometryFactory", "factory", "=", "polygon", ".", "getFactory", "(", ")", ";", "final", "LinearRing", "shell", "=", "factory", ".", "createLinearRing", "(", "getClockW...
Reverse the polygon to be oriented clockwise @param polygon @return
[ "Reverse", "the", "polygon", "to", "be", "oriented", "clockwise" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L221-L232
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java
GeometryExtrude.extrudeEdge
private static Polygon extrudeEdge(final Coordinate beginPoint, Coordinate endPoint, final double height, GeometryFactory factory) { beginPoint.z = Double.isNaN(beginPoint.z) ? 0 : beginPoint.z; endPoint.z = Double.isNaN(endPoint.z) ? 0 : endPoint.z; return factory.createPolygon(new Coordinate[]{ beginPoint, new Coordinate(beginPoint.x, beginPoint.y, beginPoint.z + height), new Coordinate(endPoint.x, endPoint.y, endPoint.z + height), endPoint, beginPoint}); }
java
private static Polygon extrudeEdge(final Coordinate beginPoint, Coordinate endPoint, final double height, GeometryFactory factory) { beginPoint.z = Double.isNaN(beginPoint.z) ? 0 : beginPoint.z; endPoint.z = Double.isNaN(endPoint.z) ? 0 : endPoint.z; return factory.createPolygon(new Coordinate[]{ beginPoint, new Coordinate(beginPoint.x, beginPoint.y, beginPoint.z + height), new Coordinate(endPoint.x, endPoint.y, endPoint.z + height), endPoint, beginPoint}); }
[ "private", "static", "Polygon", "extrudeEdge", "(", "final", "Coordinate", "beginPoint", ",", "Coordinate", "endPoint", ",", "final", "double", "height", ",", "GeometryFactory", "factory", ")", "{", "beginPoint", ".", "z", "=", "Double", ".", "isNaN", "(", "be...
Create a polygon corresponding to the wall. @param beginPoint @param endPoint @param height @return
[ "Create", "a", "polygon", "corresponding", "to", "the", "wall", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/volume/GeometryExtrude.java#L243-L253
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ColumnSRID.java
ColumnSRID.fetchConstraint
public static String fetchConstraint(Connection connection, String catalogName, String schemaName, String tableName) throws SQLException { // Merge column constraint and table constraint PreparedStatement pst = SFSUtilities.prepareInformationSchemaStatement(connection, catalogName, schemaName, tableName, "INFORMATION_SCHEMA.CONSTRAINTS", "", "TABLE_CATALOG", "TABLE_SCHEMA","TABLE_NAME"); try (ResultSet rsConstraint = pst.executeQuery()) { StringBuilder constraint = new StringBuilder(); while (rsConstraint.next()) { String tableConstr = rsConstraint.getString("CHECK_EXPRESSION"); if(tableConstr != null) { constraint.append(tableConstr); } } return constraint.toString(); } finally { pst.close(); } }
java
public static String fetchConstraint(Connection connection, String catalogName, String schemaName, String tableName) throws SQLException { // Merge column constraint and table constraint PreparedStatement pst = SFSUtilities.prepareInformationSchemaStatement(connection, catalogName, schemaName, tableName, "INFORMATION_SCHEMA.CONSTRAINTS", "", "TABLE_CATALOG", "TABLE_SCHEMA","TABLE_NAME"); try (ResultSet rsConstraint = pst.executeQuery()) { StringBuilder constraint = new StringBuilder(); while (rsConstraint.next()) { String tableConstr = rsConstraint.getString("CHECK_EXPRESSION"); if(tableConstr != null) { constraint.append(tableConstr); } } return constraint.toString(); } finally { pst.close(); } }
[ "public", "static", "String", "fetchConstraint", "(", "Connection", "connection", ",", "String", "catalogName", ",", "String", "schemaName", ",", "String", "tableName", ")", "throws", "SQLException", "{", "// Merge column constraint and table constraint", "PreparedStatement...
Read table constraints from database metadata. @param connection Active connection @param catalogName Catalog name or empty string @param schemaName Schema name or empty string @param tableName table name @return Found table constraints @throws SQLException
[ "Read", "table", "constraints", "from", "database", "metadata", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ColumnSRID.java#L82-L98
train
orbisgis/h2gis
h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUrlParser.java
JDBCUrlParser.parse
public static Properties parse(String jdbcUrl) throws IllegalArgumentException { if(!jdbcUrl.startsWith(URL_STARTS)) { throw new IllegalArgumentException("JDBC Url must start with "+URL_STARTS); } String driverAndURI = jdbcUrl.substring(URL_STARTS.length()); Properties properties = new Properties(); URI uri = URI.create(driverAndURI.substring(driverAndURI.indexOf(':')+1)); if(uri.getHost()!=null) { properties.setProperty(DataSourceFactory.JDBC_SERVER_NAME,uri.getHost()); } // Read DataBase name/path and options String path = uri.getPath(); if(path!=null) { String[] paths = path.split(";"); if(uri.getHost()!=null && paths[0].startsWith("/")) { paths[0] = paths[0].substring(1); } properties.setProperty(DataSourceFactory.JDBC_DATABASE_NAME,paths[0]); for(int id=1;id<paths.length;id++) { String[] option = paths[id].split("="); if(option.length==2) { properties.setProperty(option[0],option[1]); } } } String query = uri.getQuery(); if(query!=null) { try { for(Map.Entry<String,String> entry : URIUtilities.getQueryKeyValuePairs(uri).entrySet()) { properties.setProperty(entry.getKey(),entry.getValue()); } } catch (UnsupportedEncodingException ex) { throw new IllegalArgumentException("JDBC Url encoding error",ex); } } if(uri.getPort()!=-1) { properties.setProperty(DataSourceFactory.JDBC_PORT_NUMBER,String.valueOf(uri.getPort())); } if(uri.getScheme()!=null && !"file".equalsIgnoreCase(uri.getScheme())) { properties.setProperty(DataSourceFactory.JDBC_NETWORK_PROTOCOL, uri.getScheme()); } return properties; }
java
public static Properties parse(String jdbcUrl) throws IllegalArgumentException { if(!jdbcUrl.startsWith(URL_STARTS)) { throw new IllegalArgumentException("JDBC Url must start with "+URL_STARTS); } String driverAndURI = jdbcUrl.substring(URL_STARTS.length()); Properties properties = new Properties(); URI uri = URI.create(driverAndURI.substring(driverAndURI.indexOf(':')+1)); if(uri.getHost()!=null) { properties.setProperty(DataSourceFactory.JDBC_SERVER_NAME,uri.getHost()); } // Read DataBase name/path and options String path = uri.getPath(); if(path!=null) { String[] paths = path.split(";"); if(uri.getHost()!=null && paths[0].startsWith("/")) { paths[0] = paths[0].substring(1); } properties.setProperty(DataSourceFactory.JDBC_DATABASE_NAME,paths[0]); for(int id=1;id<paths.length;id++) { String[] option = paths[id].split("="); if(option.length==2) { properties.setProperty(option[0],option[1]); } } } String query = uri.getQuery(); if(query!=null) { try { for(Map.Entry<String,String> entry : URIUtilities.getQueryKeyValuePairs(uri).entrySet()) { properties.setProperty(entry.getKey(),entry.getValue()); } } catch (UnsupportedEncodingException ex) { throw new IllegalArgumentException("JDBC Url encoding error",ex); } } if(uri.getPort()!=-1) { properties.setProperty(DataSourceFactory.JDBC_PORT_NUMBER,String.valueOf(uri.getPort())); } if(uri.getScheme()!=null && !"file".equalsIgnoreCase(uri.getScheme())) { properties.setProperty(DataSourceFactory.JDBC_NETWORK_PROTOCOL, uri.getScheme()); } return properties; }
[ "public", "static", "Properties", "parse", "(", "String", "jdbcUrl", ")", "throws", "IllegalArgumentException", "{", "if", "(", "!", "jdbcUrl", ".", "startsWith", "(", "URL_STARTS", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"JDBC Url must s...
Convert JDBC URL into JDBC Connection properties @param jdbcUrl JDBC connection path @return Properties to be used in OSGi DataSourceFactory that does not handle {@link DataSourceFactory#JDBC_URL} @throws IllegalArgumentException Argument is not a valid JDBC connection URL or cannot be parsed by this class
[ "Convert", "JDBC", "URL", "into", "JDBC", "Connection", "properties" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/JDBCUrlParser.java#L48-L91
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_ZUpdateLineExtremities.java
ST_ZUpdateLineExtremities.updateZExtremities
public static Geometry updateZExtremities(Geometry geometry, double startZ, double endZ, boolean interpolate) { if(geometry == null){ return null; } if (geometry instanceof LineString) { return force3DStartEnd((LineString) geometry, startZ, endZ, interpolate); } else if (geometry instanceof MultiLineString) { int nbGeom = geometry.getNumGeometries(); LineString[] lines = new LineString[nbGeom]; for (int i = 0; i < nbGeom; i++) { LineString subGeom = (LineString) geometry.getGeometryN(i); lines[i] = (LineString) force3DStartEnd(subGeom, startZ, endZ, interpolate); } return FACTORY.createMultiLineString(lines); } else { return null; } }
java
public static Geometry updateZExtremities(Geometry geometry, double startZ, double endZ, boolean interpolate) { if(geometry == null){ return null; } if (geometry instanceof LineString) { return force3DStartEnd((LineString) geometry, startZ, endZ, interpolate); } else if (geometry instanceof MultiLineString) { int nbGeom = geometry.getNumGeometries(); LineString[] lines = new LineString[nbGeom]; for (int i = 0; i < nbGeom; i++) { LineString subGeom = (LineString) geometry.getGeometryN(i); lines[i] = (LineString) force3DStartEnd(subGeom, startZ, endZ, interpolate); } return FACTORY.createMultiLineString(lines); } else { return null; } }
[ "public", "static", "Geometry", "updateZExtremities", "(", "Geometry", "geometry", ",", "double", "startZ", ",", "double", "endZ", ",", "boolean", "interpolate", ")", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "if", "("...
Update the start and end Z values. If the interpolate is true the vertices are interpolated according the start and end z values. @param geometry @param startZ @param endZ @param interpolate @return
[ "Update", "the", "start", "and", "end", "Z", "values", ".", "If", "the", "interpolate", "is", "true", "the", "vertices", "are", "interpolated", "according", "the", "start", "and", "end", "z", "values", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_ZUpdateLineExtremities.java#L60-L77
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_ZUpdateLineExtremities.java
ST_ZUpdateLineExtremities.force3DStartEnd
private static Geometry force3DStartEnd(LineString lineString, final double startZ, final double endZ, final boolean interpolate) { final double bigD = lineString.getLength(); final double z = endZ - startZ; final Coordinate coordEnd = lineString.getCoordinates()[lineString.getCoordinates().length - 1]; lineString.apply(new CoordinateSequenceFilter() { boolean done = false; @Override public boolean isGeometryChanged() { return true; } @Override public boolean isDone() { return done; } @Override public void filter(CoordinateSequence seq, int i) { double x = seq.getX(i); double y = seq.getY(i); if (i == 0) { seq.setOrdinate(i, 0, x); seq.setOrdinate(i, 1, y); seq.setOrdinate(i, 2, startZ); } else if (i == seq.size() - 1) { seq.setOrdinate(i, 0, x); seq.setOrdinate(i, 1, y); seq.setOrdinate(i, 2, endZ); } else { if (interpolate) { double smallD = seq.getCoordinate(i).distance(coordEnd); double factor = smallD / bigD; seq.setOrdinate(i, 0, x); seq.setOrdinate(i, 1, y); seq.setOrdinate(i, 2, startZ + (factor * z)); } } if (i == seq.size()) { done = true; } } }); return lineString; }
java
private static Geometry force3DStartEnd(LineString lineString, final double startZ, final double endZ, final boolean interpolate) { final double bigD = lineString.getLength(); final double z = endZ - startZ; final Coordinate coordEnd = lineString.getCoordinates()[lineString.getCoordinates().length - 1]; lineString.apply(new CoordinateSequenceFilter() { boolean done = false; @Override public boolean isGeometryChanged() { return true; } @Override public boolean isDone() { return done; } @Override public void filter(CoordinateSequence seq, int i) { double x = seq.getX(i); double y = seq.getY(i); if (i == 0) { seq.setOrdinate(i, 0, x); seq.setOrdinate(i, 1, y); seq.setOrdinate(i, 2, startZ); } else if (i == seq.size() - 1) { seq.setOrdinate(i, 0, x); seq.setOrdinate(i, 1, y); seq.setOrdinate(i, 2, endZ); } else { if (interpolate) { double smallD = seq.getCoordinate(i).distance(coordEnd); double factor = smallD / bigD; seq.setOrdinate(i, 0, x); seq.setOrdinate(i, 1, y); seq.setOrdinate(i, 2, startZ + (factor * z)); } } if (i == seq.size()) { done = true; } } }); return lineString; }
[ "private", "static", "Geometry", "force3DStartEnd", "(", "LineString", "lineString", ",", "final", "double", "startZ", ",", "final", "double", "endZ", ",", "final", "boolean", "interpolate", ")", "{", "final", "double", "bigD", "=", "lineString", ".", "getLength...
Updates all z values by a new value using the specified first and the last coordinates. @param geom @param startZ @param endZ @param interpolate is true the z value of the vertices are interpolate according the length of the line. @return
[ "Updates", "all", "z", "values", "by", "a", "new", "value", "using", "the", "specified", "first", "and", "the", "last", "coordinates", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_ZUpdateLineExtremities.java#L90-L135
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/StringStack.java
StringStack.push
public boolean push(String newText) { if (stackTop < stack.length - 1) { stack[stackTop++] = newText; return true; } else { return false; } }
java
public boolean push(String newText) { if (stackTop < stack.length - 1) { stack[stackTop++] = newText; return true; } else { return false; } }
[ "public", "boolean", "push", "(", "String", "newText", ")", "{", "if", "(", "stackTop", "<", "stack", ".", "length", "-", "1", ")", "{", "stack", "[", "stackTop", "++", "]", "=", "newText", ";", "return", "true", ";", "}", "else", "{", "return", "f...
Puts string in the stack. @param newText A new string to put in the stack @return false if the stack is full
[ "Puts", "string", "in", "the", "stack", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/StringStack.java#L49-L56
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/utility/ReadBufferManager.java
ReadBufferManager.getWindowOffset
private int getWindowOffset(long bytePos, int length) throws IOException { long desiredMax = bytePos + length - 1; if ((bytePos >= windowStart) && (desiredMax < windowStart + buffer.capacity())) { long res = bytePos - windowStart; if (res < Integer.MAX_VALUE) { return (int) res; } else { throw new IOException("This buffer is quite large..."); } } else { long bufferCapacity = Math.max(bufferSize, length); long size = channel.size(); bufferCapacity = Math.min(bufferCapacity, size - bytePos); if (bufferCapacity > Integer.MAX_VALUE) { throw new IOException("Woaw ! You want to have a REALLY LARGE buffer !"); } windowStart = bytePos; channel.position(windowStart); if (buffer.capacity() != bufferCapacity) { ByteOrder order = buffer.order(); buffer = ByteBuffer.allocate((int)bufferCapacity); buffer.order(order); } else { buffer.clear(); } channel.read(buffer); buffer.flip(); return (int) (bytePos - windowStart); } }
java
private int getWindowOffset(long bytePos, int length) throws IOException { long desiredMax = bytePos + length - 1; if ((bytePos >= windowStart) && (desiredMax < windowStart + buffer.capacity())) { long res = bytePos - windowStart; if (res < Integer.MAX_VALUE) { return (int) res; } else { throw new IOException("This buffer is quite large..."); } } else { long bufferCapacity = Math.max(bufferSize, length); long size = channel.size(); bufferCapacity = Math.min(bufferCapacity, size - bytePos); if (bufferCapacity > Integer.MAX_VALUE) { throw new IOException("Woaw ! You want to have a REALLY LARGE buffer !"); } windowStart = bytePos; channel.position(windowStart); if (buffer.capacity() != bufferCapacity) { ByteOrder order = buffer.order(); buffer = ByteBuffer.allocate((int)bufferCapacity); buffer.order(order); } else { buffer.clear(); } channel.read(buffer); buffer.flip(); return (int) (bytePos - windowStart); } }
[ "private", "int", "getWindowOffset", "(", "long", "bytePos", ",", "int", "length", ")", "throws", "IOException", "{", "long", "desiredMax", "=", "bytePos", "+", "length", "-", "1", ";", "if", "(", "(", "bytePos", ">=", "windowStart", ")", "&&", "(", "des...
Moves the window if necessary to contain the desired byte and returns the position of the byte in the window @param bytePos @throws java.io.IOException
[ "Moves", "the", "window", "if", "necessary", "to", "contain", "the", "desired", "byte", "and", "returns", "the", "position", "of", "the", "byte", "in", "the", "window" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/utility/ReadBufferManager.java#L70-L102
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java
SunCalc.getJulianCycle
private static long getJulianCycle(double J, double lw) { return Math.round(J - J2000 - J0 - lw / (2 * Math.PI)); }
java
private static long getJulianCycle(double J, double lw) { return Math.round(J - J2000 - J0 - lw / (2 * Math.PI)); }
[ "private", "static", "long", "getJulianCycle", "(", "double", "J", ",", "double", "lw", ")", "{", "return", "Math", ".", "round", "(", "J", "-", "J2000", "-", "J0", "-", "lw", "/", "(", "2", "*", "Math", ".", "PI", ")", ")", ";", "}" ]
general sun calculations
[ "general", "sun", "calculations" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java#L72-L74
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java
SunCalc.getApproxTransit
private static double getApproxTransit(double Ht, double lw, double n) { return J2000 + J0 + (Ht + lw) / (2 * Math.PI) + n; }
java
private static double getApproxTransit(double Ht, double lw, double n) { return J2000 + J0 + (Ht + lw) / (2 * Math.PI) + n; }
[ "private", "static", "double", "getApproxTransit", "(", "double", "Ht", ",", "double", "lw", ",", "double", "n", ")", "{", "return", "J2000", "+", "J0", "+", "(", "Ht", "+", "lw", ")", "/", "(", "2", "*", "Math", ".", "PI", ")", "+", "n", ";", ...
calculations for sun times
[ "calculations", "for", "sun", "times" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java#L93-L95
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java
SunCalc.getRightAscension
private static double getRightAscension(double Ls) { return Math.atan2(Math.sin(Ls) * Math.cos(e), Math.cos(Ls)); }
java
private static double getRightAscension(double Ls) { return Math.atan2(Math.sin(Ls) * Math.cos(e), Math.cos(Ls)); }
[ "private", "static", "double", "getRightAscension", "(", "double", "Ls", ")", "{", "return", "Math", ".", "atan2", "(", "Math", ".", "sin", "(", "Ls", ")", "*", "Math", ".", "cos", "(", "e", ")", ",", "Math", ".", "cos", "(", "Ls", ")", ")", ";",...
calculations for sun position
[ "calculations", "for", "sun", "position" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java#L107-L109
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java
SunCalc.getPosition
public static Coordinate getPosition(Date date, double lat, double lng) { if (isGeographic(lat, lng)) { double lw = rad * -lng; double phi = rad * lat; double J = dateToJulianDate(date); double M = getSolarMeanAnomaly(J); double C = getEquationOfCenter(M); double Ls = getEclipticLongitude(M, C); double d = getSunDeclination(Ls); double a = getRightAscension(Ls); double th = getSiderealTime(J, lw); double H = th - a; return new Coordinate(getAzimuth(H, phi, d),getAltitude(H, phi, d)); } else { throw new IllegalArgumentException("The coordinate of the point must in latitude and longitude."); } }
java
public static Coordinate getPosition(Date date, double lat, double lng) { if (isGeographic(lat, lng)) { double lw = rad * -lng; double phi = rad * lat; double J = dateToJulianDate(date); double M = getSolarMeanAnomaly(J); double C = getEquationOfCenter(M); double Ls = getEclipticLongitude(M, C); double d = getSunDeclination(Ls); double a = getRightAscension(Ls); double th = getSiderealTime(J, lw); double H = th - a; return new Coordinate(getAzimuth(H, phi, d),getAltitude(H, phi, d)); } else { throw new IllegalArgumentException("The coordinate of the point must in latitude and longitude."); } }
[ "public", "static", "Coordinate", "getPosition", "(", "Date", "date", ",", "double", "lat", ",", "double", "lng", ")", "{", "if", "(", "isGeographic", "(", "lat", ",", "lng", ")", ")", "{", "double", "lw", "=", "rad", "*", "-", "lng", ";", "double", ...
Returns the sun position as a coordinate with the following properties x: sun azimuth in radians (direction along the horizon, measured from south to west), e.g. 0 is south and Math.PI * 3/4 is northwest. y: sun altitude above the horizon in radians, e.g. 0 at the horizon and PI/2 at the zenith (straight over your head). @param date @param lat @param lng @return
[ "Returns", "the", "sun", "position", "as", "a", "coordinate", "with", "the", "following", "properties" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java#L155-L172
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/shp/internal/IndexFile.java
IndexFile.getContentLength
public int getContentLength(int index) throws IOException { int ret = -1; if (this.lastIndex != index) { this.readRecord(index); } ret = this.recLen; return ret; }
java
public int getContentLength(int index) throws IOException { int ret = -1; if (this.lastIndex != index) { this.readRecord(index); } ret = this.recLen; return ret; }
[ "public", "int", "getContentLength", "(", "int", "index", ")", "throws", "IOException", "{", "int", "ret", "=", "-", "1", ";", "if", "(", "this", ".", "lastIndex", "!=", "index", ")", "{", "this", ".", "readRecord", "(", "index", ")", ";", "}", "ret"...
Get the content length of the given record in bytes, not 16 bit words. @param index The index, from 0 to getRecordCount - 1 @return The lengh in bytes of the record. @throws java.io.IOException
[ "Get", "the", "content", "length", "of", "the", "given", "record", "in", "bytes", "not", "16", "bit", "words", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/shp/internal/IndexFile.java#L152-L162
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_Reverse.java
ST_Reverse.reverse
public static Geometry reverse(Geometry geometry) { if (geometry == null) { return null; } if (geometry instanceof MultiPoint) { return reverseMultiPoint((MultiPoint) geometry); } return geometry.reverse(); }
java
public static Geometry reverse(Geometry geometry) { if (geometry == null) { return null; } if (geometry instanceof MultiPoint) { return reverseMultiPoint((MultiPoint) geometry); } return geometry.reverse(); }
[ "public", "static", "Geometry", "reverse", "(", "Geometry", "geometry", ")", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "geometry", "instanceof", "MultiPoint", ")", "{", "return", "reverseMultiPoint", "(", "(...
Returns the geometry with vertex order reversed. @param geometry Geometry @return geometry with vertex order reversed
[ "Returns", "the", "geometry", "with", "vertex", "order", "reversed", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_Reverse.java#L51-L59
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_Reverse.java
ST_Reverse.reverseMultiPoint
public static Geometry reverseMultiPoint(MultiPoint mp) { int nPoints = mp.getNumGeometries(); Point[] revPoints = new Point[nPoints]; for (int i = 0; i < nPoints; i++) { revPoints[nPoints - 1 - i] = (Point) mp.getGeometryN(i).reverse(); } return mp.getFactory().createMultiPoint(revPoints); }
java
public static Geometry reverseMultiPoint(MultiPoint mp) { int nPoints = mp.getNumGeometries(); Point[] revPoints = new Point[nPoints]; for (int i = 0; i < nPoints; i++) { revPoints[nPoints - 1 - i] = (Point) mp.getGeometryN(i).reverse(); } return mp.getFactory().createMultiPoint(revPoints); }
[ "public", "static", "Geometry", "reverseMultiPoint", "(", "MultiPoint", "mp", ")", "{", "int", "nPoints", "=", "mp", ".", "getNumGeometries", "(", ")", ";", "Point", "[", "]", "revPoints", "=", "new", "Point", "[", "nPoints", "]", ";", "for", "(", "int",...
Returns the MultiPoint with vertex order reversed. We do our own implementation here because JTS does not handle it. @param mp MultiPoint @return MultiPoint with vertex order reversed
[ "Returns", "the", "MultiPoint", "with", "vertex", "order", "reversed", ".", "We", "do", "our", "own", "implementation", "here", "because", "JTS", "does", "not", "handle", "it", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_Reverse.java#L68-L75
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_MakeEnvelope.java
ST_MakeEnvelope.makeEnvelope
public static Polygon makeEnvelope(double xmin, double ymin, double xmax, double ymax) { Coordinate[] coordinates = new Coordinate[]{ new Coordinate(xmin, ymin), new Coordinate(xmax, ymin), new Coordinate(xmax, ymax), new Coordinate(xmin, ymax), new Coordinate(xmin, ymin) }; return GF.createPolygon(GF.createLinearRing(coordinates), null); }
java
public static Polygon makeEnvelope(double xmin, double ymin, double xmax, double ymax) { Coordinate[] coordinates = new Coordinate[]{ new Coordinate(xmin, ymin), new Coordinate(xmax, ymin), new Coordinate(xmax, ymax), new Coordinate(xmin, ymax), new Coordinate(xmin, ymin) }; return GF.createPolygon(GF.createLinearRing(coordinates), null); }
[ "public", "static", "Polygon", "makeEnvelope", "(", "double", "xmin", ",", "double", "ymin", ",", "double", "xmax", ",", "double", "ymax", ")", "{", "Coordinate", "[", "]", "coordinates", "=", "new", "Coordinate", "[", "]", "{", "new", "Coordinate", "(", ...
Creates a rectangular Polygon formed from the minima and maxima by the given shell. @param xmin X min @param ymin Y min @param xmax X max @param ymax Y max @return Envelope as a POLYGON
[ "Creates", "a", "rectangular", "Polygon", "formed", "from", "the", "minima", "and", "maxima", "by", "the", "given", "shell", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_MakeEnvelope.java#L59-L68
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_MakeEnvelope.java
ST_MakeEnvelope.makeEnvelope
public static Polygon makeEnvelope(double xmin, double ymin, double xmax, double ymax, int srid) { Polygon geom = makeEnvelope(xmin, ymin, xmax, ymax); geom.setSRID(srid); return geom; }
java
public static Polygon makeEnvelope(double xmin, double ymin, double xmax, double ymax, int srid) { Polygon geom = makeEnvelope(xmin, ymin, xmax, ymax); geom.setSRID(srid); return geom; }
[ "public", "static", "Polygon", "makeEnvelope", "(", "double", "xmin", ",", "double", "ymin", ",", "double", "xmax", ",", "double", "ymax", ",", "int", "srid", ")", "{", "Polygon", "geom", "=", "makeEnvelope", "(", "xmin", ",", "ymin", ",", "xmax", ",", ...
Creates a rectangular Polygon formed from the minima and maxima by the given shell. The user can set a srid. @param xmin X min @param ymin Y min @param xmax X max @param ymax Y max @param srid SRID @return Envelope as a POLYGON
[ "Creates", "a", "rectangular", "Polygon", "formed", "from", "the", "minima", "and", "maxima", "by", "the", "given", "shell", ".", "The", "user", "can", "set", "a", "srid", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_MakeEnvelope.java#L81-L85
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/generalize/ST_Simplify.java
ST_Simplify.simplify
public static Geometry simplify(Geometry geometry, double distance) { if(geometry == null){ return null; } return DouglasPeuckerSimplifier.simplify(geometry, distance); }
java
public static Geometry simplify(Geometry geometry, double distance) { if(geometry == null){ return null; } return DouglasPeuckerSimplifier.simplify(geometry, distance); }
[ "public", "static", "Geometry", "simplify", "(", "Geometry", "geometry", ",", "double", "distance", ")", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "return", "DouglasPeuckerSimplifier", ".", "simplify", "(", "geometry", "...
Simplify the geometry using the douglad peucker algorithm. @param geometry @param distance @return
[ "Simplify", "the", "geometry", "using", "the", "douglad", "peucker", "algorithm", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/generalize/ST_Simplify.java#L51-L56
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_Expand.java
ST_Expand.expand
public static Geometry expand(Geometry geometry, double deltaX, double deltaY) { if(geometry == null){ return null; } Envelope env = geometry.getEnvelopeInternal(); // As the time of writing Envelope.expand is buggy with negative parameters double minX = env.getMinX() - deltaX; double maxX = env.getMaxX() + deltaX; double minY = env.getMinY() - deltaY; double maxY = env.getMaxY() + deltaY; Envelope expandedEnvelope = new Envelope(minX < maxX ? minX : (env.getMaxX() - env.getMinX()) / 2 + env.getMinX(), minX < maxX ? maxX : (env.getMaxX() - env.getMinX()) / 2 + env.getMinX(), minY < maxY ? minY : (env.getMaxY() - env.getMinY()) / 2 + env.getMinY(), minY < maxY ? maxY : (env.getMaxY() - env.getMinY()) / 2 + env.getMinY()); return geometry.getFactory().toGeometry(expandedEnvelope); }
java
public static Geometry expand(Geometry geometry, double deltaX, double deltaY) { if(geometry == null){ return null; } Envelope env = geometry.getEnvelopeInternal(); // As the time of writing Envelope.expand is buggy with negative parameters double minX = env.getMinX() - deltaX; double maxX = env.getMaxX() + deltaX; double minY = env.getMinY() - deltaY; double maxY = env.getMaxY() + deltaY; Envelope expandedEnvelope = new Envelope(minX < maxX ? minX : (env.getMaxX() - env.getMinX()) / 2 + env.getMinX(), minX < maxX ? maxX : (env.getMaxX() - env.getMinX()) / 2 + env.getMinX(), minY < maxY ? minY : (env.getMaxY() - env.getMinY()) / 2 + env.getMinY(), minY < maxY ? maxY : (env.getMaxY() - env.getMinY()) / 2 + env.getMinY()); return geometry.getFactory().toGeometry(expandedEnvelope); }
[ "public", "static", "Geometry", "expand", "(", "Geometry", "geometry", ",", "double", "deltaX", ",", "double", "deltaY", ")", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "Envelope", "env", "=", "geometry", ".", "getEnv...
Expands a geometry's envelope by the given delta X and delta Y. Both positive and negative distances are supported. @param geometry the input geometry @param deltaX the distance to expand the envelope along the X axis @param deltaY the distance to expand the envelope along the Y axis @return the expanded geometry
[ "Expands", "a", "geometry", "s", "envelope", "by", "the", "given", "delta", "X", "and", "delta", "Y", ".", "Both", "positive", "and", "negative", "distances", "are", "supported", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_Expand.java#L65-L80
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_TriangleDirection.java
ST_TriangleDirection.computeDirection
public static LineString computeDirection(Geometry geometry) throws IllegalArgumentException { if(geometry == null){ return null; } // Convert geometry into triangle Triangle triangle = TINFeatureFactory.createTriangle(geometry); // Compute slope vector Vector3D normal = TriMarkers.getNormalVector(triangle); Vector3D vector = new Vector3D(normal.getX(), normal.getY(), 0).normalize(); // Compute equidistant point of triangle's sides Coordinate inCenter = triangle.centroid(); // Interpolate Z value inCenter.setOrdinate(2, Triangle.interpolateZ(inCenter, triangle.p0, triangle.p1, triangle.p2)); // Project slope from triangle center to triangle borders final LineSegment[] sides = new LineSegment[] {new LineSegment(triangle.p0, triangle.p1), new LineSegment(triangle.p1, triangle.p2), new LineSegment(triangle.p2, triangle.p0)}; Coordinate pointIntersection = null; double nearestIntersection = Double.MAX_VALUE; for(LineSegment side : sides) { Coordinate intersection = CoordinateUtils.vectorIntersection(inCenter, vector, side.p0, new Vector3D(side.p0,side.p1).normalize()); double distInters = intersection == null ? Double.MAX_VALUE : side.distance(intersection); if(intersection != null && distInters < nearestIntersection) { pointIntersection = new Coordinate(intersection.x, intersection.y, Triangle.interpolateZ(intersection, triangle.p0, triangle.p1, triangle.p2)); nearestIntersection = distInters; } } if (pointIntersection != null) { return gf.createLineString(new Coordinate[]{inCenter, pointIntersection}); } return gf.createLineString(new Coordinate[] {}); }
java
public static LineString computeDirection(Geometry geometry) throws IllegalArgumentException { if(geometry == null){ return null; } // Convert geometry into triangle Triangle triangle = TINFeatureFactory.createTriangle(geometry); // Compute slope vector Vector3D normal = TriMarkers.getNormalVector(triangle); Vector3D vector = new Vector3D(normal.getX(), normal.getY(), 0).normalize(); // Compute equidistant point of triangle's sides Coordinate inCenter = triangle.centroid(); // Interpolate Z value inCenter.setOrdinate(2, Triangle.interpolateZ(inCenter, triangle.p0, triangle.p1, triangle.p2)); // Project slope from triangle center to triangle borders final LineSegment[] sides = new LineSegment[] {new LineSegment(triangle.p0, triangle.p1), new LineSegment(triangle.p1, triangle.p2), new LineSegment(triangle.p2, triangle.p0)}; Coordinate pointIntersection = null; double nearestIntersection = Double.MAX_VALUE; for(LineSegment side : sides) { Coordinate intersection = CoordinateUtils.vectorIntersection(inCenter, vector, side.p0, new Vector3D(side.p0,side.p1).normalize()); double distInters = intersection == null ? Double.MAX_VALUE : side.distance(intersection); if(intersection != null && distInters < nearestIntersection) { pointIntersection = new Coordinate(intersection.x, intersection.y, Triangle.interpolateZ(intersection, triangle.p0, triangle.p1, triangle.p2)); nearestIntersection = distInters; } } if (pointIntersection != null) { return gf.createLineString(new Coordinate[]{inCenter, pointIntersection}); } return gf.createLineString(new Coordinate[] {}); }
[ "public", "static", "LineString", "computeDirection", "(", "Geometry", "geometry", ")", "throws", "IllegalArgumentException", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "// Convert geometry into triangle", "Triangle", "triangle", ...
Compute the main slope direction @param geometry @return @throws IllegalArgumentException
[ "Compute", "the", "main", "slope", "direction" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_TriangleDirection.java#L55-L87
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java
ST_Drape.drapePoints
public static Geometry drapePoints(Geometry pts, Geometry triangles, STRtree sTRtree) { Geometry geomDrapped = pts.copy(); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); geomDrapped.apply(drapeFilter); return geomDrapped; }
java
public static Geometry drapePoints(Geometry pts, Geometry triangles, STRtree sTRtree) { Geometry geomDrapped = pts.copy(); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); geomDrapped.apply(drapeFilter); return geomDrapped; }
[ "public", "static", "Geometry", "drapePoints", "(", "Geometry", "pts", ",", "Geometry", "triangles", ",", "STRtree", "sTRtree", ")", "{", "Geometry", "geomDrapped", "=", "pts", ".", "copy", "(", ")", ";", "CoordinateSequenceFilter", "drapeFilter", "=", "new", ...
Drape a point or a multipoint geometry to a set of triangles @param pts @param triangles @param sTRtree @return
[ "Drape", "a", "point", "or", "a", "multipoint", "geometry", "to", "a", "set", "of", "triangles" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java#L91-L96
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java
ST_Drape.drapeLineString
public static Geometry drapeLineString(LineString line, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = line.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); Geometry diffExt = lineMerge(line.difference(triangleLines), factory); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); diffExt.apply(drapeFilter); return diffExt; }
java
public static Geometry drapeLineString(LineString line, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = line.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); Geometry diffExt = lineMerge(line.difference(triangleLines), factory); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); diffExt.apply(drapeFilter); return diffExt; }
[ "public", "static", "Geometry", "drapeLineString", "(", "LineString", "line", ",", "Geometry", "triangles", ",", "STRtree", "sTRtree", ")", "{", "GeometryFactory", "factory", "=", "line", ".", "getFactory", "(", ")", ";", "//Split the triangles in lines to perform all...
Drape a linestring to a set of triangles @param line @param triangles @param sTRtree @return
[ "Drape", "a", "linestring", "to", "a", "set", "of", "triangles" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java#L150-L158
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java
ST_Drape.drapePolygon
public static Geometry drapePolygon(Polygon p, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = p.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); Polygon splittedP = processPolygon(p, triangleLines, factory); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); splittedP.apply(drapeFilter); return splittedP; }
java
public static Geometry drapePolygon(Polygon p, Geometry triangles, STRtree sTRtree) { GeometryFactory factory = p.getFactory(); //Split the triangles in lines to perform all intersections Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true); Polygon splittedP = processPolygon(p, triangleLines, factory); CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree); splittedP.apply(drapeFilter); return splittedP; }
[ "public", "static", "Geometry", "drapePolygon", "(", "Polygon", "p", ",", "Geometry", "triangles", ",", "STRtree", "sTRtree", ")", "{", "GeometryFactory", "factory", "=", "p", ".", "getFactory", "(", ")", ";", "//Split the triangles in lines to perform all intersectio...
Drape a polygon on a set of triangles @param p @param triangles @param sTRtree @return
[ "Drape", "a", "polygon", "on", "a", "set", "of", "triangles" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java#L167-L175
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java
ST_Drape.processPolygon
private static Polygon processPolygon(Polygon p, Geometry triangleLines, GeometryFactory factory) { Geometry diffExt = p.getExteriorRing().difference(triangleLines); final int nbOfHoles = p.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { holes[i] = factory.createLinearRing(lineMerge(p.getInteriorRingN(i).difference(triangleLines), factory).getCoordinates()); } return factory.createPolygon(factory.createLinearRing(lineMerge(diffExt, factory).getCoordinates()), holes); }
java
private static Polygon processPolygon(Polygon p, Geometry triangleLines, GeometryFactory factory) { Geometry diffExt = p.getExteriorRing().difference(triangleLines); final int nbOfHoles = p.getNumInteriorRing(); final LinearRing[] holes = new LinearRing[nbOfHoles]; for (int i = 0; i < nbOfHoles; i++) { holes[i] = factory.createLinearRing(lineMerge(p.getInteriorRingN(i).difference(triangleLines), factory).getCoordinates()); } return factory.createPolygon(factory.createLinearRing(lineMerge(diffExt, factory).getCoordinates()), holes); }
[ "private", "static", "Polygon", "processPolygon", "(", "Polygon", "p", ",", "Geometry", "triangleLines", ",", "GeometryFactory", "factory", ")", "{", "Geometry", "diffExt", "=", "p", ".", "getExteriorRing", "(", ")", ".", "difference", "(", "triangleLines", ")",...
Cut the lines of the polygon with the triangles @param p @param triangleLines @param factory @return
[ "Cut", "the", "lines", "of", "the", "polygon", "with", "the", "triangles" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java#L184-L193
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java
ST_Drape.lineMerge
public static Geometry lineMerge(Geometry geom, GeometryFactory factory) { LineMerger merger = new LineMerger(); merger.add(geom); Collection lines = merger.getMergedLineStrings(); return factory.buildGeometry(lines); }
java
public static Geometry lineMerge(Geometry geom, GeometryFactory factory) { LineMerger merger = new LineMerger(); merger.add(geom); Collection lines = merger.getMergedLineStrings(); return factory.buildGeometry(lines); }
[ "public", "static", "Geometry", "lineMerge", "(", "Geometry", "geom", ",", "GeometryFactory", "factory", ")", "{", "LineMerger", "merger", "=", "new", "LineMerger", "(", ")", ";", "merger", ".", "add", "(", "geom", ")", ";", "Collection", "lines", "=", "me...
A method to merge a geometry to a set of linestring @param geom @param factory @return
[ "A", "method", "to", "merge", "a", "geometry", "to", "a", "set", "of", "linestring" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_Drape.java#L201-L206
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/generalize/ST_PrecisionReducer.java
ST_PrecisionReducer.precisionReducer
public static Geometry precisionReducer(Geometry geometry, int nbDec) throws SQLException { if(geometry == null){ return null; } if (nbDec < 0) { throw new SQLException("Decimal_places has to be >= 0."); } PrecisionModel pm = new PrecisionModel(scaleFactorForDecimalPlaces(nbDec)); GeometryPrecisionReducer geometryPrecisionReducer = new GeometryPrecisionReducer(pm); return geometryPrecisionReducer.reduce(geometry); }
java
public static Geometry precisionReducer(Geometry geometry, int nbDec) throws SQLException { if(geometry == null){ return null; } if (nbDec < 0) { throw new SQLException("Decimal_places has to be >= 0."); } PrecisionModel pm = new PrecisionModel(scaleFactorForDecimalPlaces(nbDec)); GeometryPrecisionReducer geometryPrecisionReducer = new GeometryPrecisionReducer(pm); return geometryPrecisionReducer.reduce(geometry); }
[ "public", "static", "Geometry", "precisionReducer", "(", "Geometry", "geometry", ",", "int", "nbDec", ")", "throws", "SQLException", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "nbDec", "<", "0", ")", "{", ...
Reduce the geometry precision. Decimal_Place is the number of decimals to keep. @param geometry @param nbDec @return @throws SQLException
[ "Reduce", "the", "geometry", "precision", ".", "Decimal_Place", "is", "the", "number", "of", "decimals", "to", "keep", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/generalize/ST_PrecisionReducer.java#L54-L64
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/buffer/ST_RingSideBuffer.java
ST_RingSideBuffer.ringSideBuffer
public static Geometry ringSideBuffer(Geometry geom, double bufferSize, int numBuffer) throws SQLException { return ringSideBuffer(geom, bufferSize, numBuffer, "endcap=flat"); }
java
public static Geometry ringSideBuffer(Geometry geom, double bufferSize, int numBuffer) throws SQLException { return ringSideBuffer(geom, bufferSize, numBuffer, "endcap=flat"); }
[ "public", "static", "Geometry", "ringSideBuffer", "(", "Geometry", "geom", ",", "double", "bufferSize", ",", "int", "numBuffer", ")", "throws", "SQLException", "{", "return", "ringSideBuffer", "(", "geom", ",", "bufferSize", ",", "numBuffer", ",", "\"endcap=flat\"...
Compute a ring buffer on one side of the geometry @param geom @param bufferSize @param numBuffer @return @throws java.sql.SQLException
[ "Compute", "a", "ring", "buffer", "on", "one", "side", "of", "the", "geometry" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/buffer/ST_RingSideBuffer.java#L65-L67
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_TriangleAspect.java
ST_TriangleAspect.computeAspect
public static Double computeAspect(Geometry geometry) throws IllegalArgumentException { if (geometry == null) { return null; } Vector3D vector = TriMarkers.getSteepestVector(TriMarkers.getNormalVector(TINFeatureFactory.createTriangle(geometry)), TINFeatureFactory.EPSILON); if (vector.length() < TINFeatureFactory.EPSILON) { return 0d; } else { Vector2D v = new Vector2D(vector.getX(), vector.getY()); return measureFromNorth(Math.toDegrees(v.angle())); } }
java
public static Double computeAspect(Geometry geometry) throws IllegalArgumentException { if (geometry == null) { return null; } Vector3D vector = TriMarkers.getSteepestVector(TriMarkers.getNormalVector(TINFeatureFactory.createTriangle(geometry)), TINFeatureFactory.EPSILON); if (vector.length() < TINFeatureFactory.EPSILON) { return 0d; } else { Vector2D v = new Vector2D(vector.getX(), vector.getY()); return measureFromNorth(Math.toDegrees(v.angle())); } }
[ "public", "static", "Double", "computeAspect", "(", "Geometry", "geometry", ")", "throws", "IllegalArgumentException", "{", "if", "(", "geometry", "==", "null", ")", "{", "return", "null", ";", "}", "Vector3D", "vector", "=", "TriMarkers", ".", "getSteepestVecto...
Compute the aspect in degree. The geometry must be a triangle. @param geometry Polygon triangle @return aspect in degree @throws IllegalArgumentException ST_TriangleAspect accept only triangles
[ "Compute", "the", "aspect", "in", "degree", ".", "The", "geometry", "must", "be", "a", "triangle", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topography/ST_TriangleAspect.java#L53-L64
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_ZMin.java
ST_ZMin.getMinZ
public static Double getMinZ(Geometry geom) { if (geom != null) { return CoordinateUtils.zMinMax(geom.getCoordinates())[0]; } else { return null; } }
java
public static Double getMinZ(Geometry geom) { if (geom != null) { return CoordinateUtils.zMinMax(geom.getCoordinates())[0]; } else { return null; } }
[ "public", "static", "Double", "getMinZ", "(", "Geometry", "geom", ")", "{", "if", "(", "geom", "!=", "null", ")", "{", "return", "CoordinateUtils", ".", "zMinMax", "(", "geom", ".", "getCoordinates", "(", ")", ")", "[", "0", "]", ";", "}", "else", "{...
Returns the minimal z-value of the given geometry. @param geom Geometry @return The minimal z-value of the given geometry, or null if the geometry is null.
[ "Returns", "the", "minimal", "z", "-", "value", "of", "the", "given", "geometry", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_ZMin.java#L49-L55
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_Reverse3DLine.java
ST_Reverse3DLine.reverse3D
private static LineString reverse3D(LineString lineString, String order) { CoordinateSequence seq = lineString.getCoordinateSequence(); double startZ = seq.getCoordinate(0).z; double endZ = seq.getCoordinate(seq.size() - 1).z; if (order.equalsIgnoreCase("desc")) { if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ < endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } } else if (order.equalsIgnoreCase("asc")) { if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ > endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } } else { throw new IllegalArgumentException("Supported order values are asc or desc."); } return lineString; }
java
private static LineString reverse3D(LineString lineString, String order) { CoordinateSequence seq = lineString.getCoordinateSequence(); double startZ = seq.getCoordinate(0).z; double endZ = seq.getCoordinate(seq.size() - 1).z; if (order.equalsIgnoreCase("desc")) { if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ < endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } } else if (order.equalsIgnoreCase("asc")) { if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ > endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } } else { throw new IllegalArgumentException("Supported order values are asc or desc."); } return lineString; }
[ "private", "static", "LineString", "reverse3D", "(", "LineString", "lineString", ",", "String", "order", ")", "{", "CoordinateSequence", "seq", "=", "lineString", ".", "getCoordinateSequence", "(", ")", ";", "double", "startZ", "=", "seq", ".", "getCoordinate", ...
Reverses a LineString according to the z value. The z of the first point must be lower than the z of the end point. @param lineString @return
[ "Reverses", "a", "LineString", "according", "to", "the", "z", "value", ".", "The", "z", "of", "the", "first", "point", "must", "be", "lower", "than", "the", "z", "of", "the", "end", "point", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_Reverse3DLine.java#L87-L106
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GoogleMapLink.java
ST_GoogleMapLink.generateGMLink
public static String generateGMLink(Geometry geom, String layerType, int zoom) { if (geom == null) { return null; } try { LayerType layer = LayerType.valueOf(layerType.toLowerCase()); Coordinate centre = geom.getEnvelopeInternal().centre(); StringBuilder sb = new StringBuilder("https://maps.google.com/maps?ll="); sb.append(centre.y); sb.append(","); sb.append(centre.x); sb.append("&z="); sb.append(zoom); sb.append("&t="); sb.append(layer.name()); return sb.toString(); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Layer type supported are m (normal map) , k (satellite), h (hybrid), p (terrain)", ex); } }
java
public static String generateGMLink(Geometry geom, String layerType, int zoom) { if (geom == null) { return null; } try { LayerType layer = LayerType.valueOf(layerType.toLowerCase()); Coordinate centre = geom.getEnvelopeInternal().centre(); StringBuilder sb = new StringBuilder("https://maps.google.com/maps?ll="); sb.append(centre.y); sb.append(","); sb.append(centre.x); sb.append("&z="); sb.append(zoom); sb.append("&t="); sb.append(layer.name()); return sb.toString(); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Layer type supported are m (normal map) , k (satellite), h (hybrid), p (terrain)", ex); } }
[ "public", "static", "String", "generateGMLink", "(", "Geometry", "geom", ",", "String", "layerType", ",", "int", "zoom", ")", "{", "if", "(", "geom", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "LayerType", "layer", "=", "LayerType", ...
Generate a Google Map link URL based on the center of the bounding box of the input geometry. Set the layer type and the zoom level. @param geom @param layerType @param zoom @return
[ "Generate", "a", "Google", "Map", "link", "URL", "based", "on", "the", "center", "of", "the", "bounding", "box", "of", "the", "input", "geometry", ".", "Set", "the", "layer", "type", "and", "the", "zoom", "level", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GoogleMapLink.java#L78-L97
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/mesh/FullConvexHull.java
FullConvexHull.toCoordinateArray
protected Coordinate[] toCoordinateArray(Stack stack) { Coordinate[] coordinates = new Coordinate[stack.size()]; for (int i = 0; i < stack.size(); i++) { Coordinate coordinate = (Coordinate) stack.get(i); coordinates[i] = coordinate; } return coordinates; }
java
protected Coordinate[] toCoordinateArray(Stack stack) { Coordinate[] coordinates = new Coordinate[stack.size()]; for (int i = 0; i < stack.size(); i++) { Coordinate coordinate = (Coordinate) stack.get(i); coordinates[i] = coordinate; } return coordinates; }
[ "protected", "Coordinate", "[", "]", "toCoordinateArray", "(", "Stack", "stack", ")", "{", "Coordinate", "[", "]", "coordinates", "=", "new", "Coordinate", "[", "stack", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<"...
An alternative to Stack.toArray, which is not present in earlier versions of Java. @param stack
[ "An", "alternative", "to", "Stack", ".", "toArray", "which", "is", "not", "present", "in", "earlier", "versions", "of", "Java", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/mesh/FullConvexHull.java#L117-L124
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/mesh/FullConvexHull.java
FullConvexHull.grahamScan
private Stack grahamScan(Coordinate[] c) { Coordinate p; Stack ps = new Stack(); p = (Coordinate) ps.push(c[0]); p = (Coordinate) ps.push(c[1]); p = (Coordinate) ps.push(c[2]); for (int i = 3; i < c.length; i++) { p = (Coordinate) ps.pop(); // check for empty stack to guard against robustness problems while ( ! ps.empty() && CGAlgorithms.computeOrientation((Coordinate) ps.peek(), p, c[i]) > 0) { p = (Coordinate) ps.pop(); } p = (Coordinate) ps.push(p); p = (Coordinate) ps.push(c[i]); } p = (Coordinate) ps.push(c[0]); return ps; }
java
private Stack grahamScan(Coordinate[] c) { Coordinate p; Stack ps = new Stack(); p = (Coordinate) ps.push(c[0]); p = (Coordinate) ps.push(c[1]); p = (Coordinate) ps.push(c[2]); for (int i = 3; i < c.length; i++) { p = (Coordinate) ps.pop(); // check for empty stack to guard against robustness problems while ( ! ps.empty() && CGAlgorithms.computeOrientation((Coordinate) ps.peek(), p, c[i]) > 0) { p = (Coordinate) ps.pop(); } p = (Coordinate) ps.push(p); p = (Coordinate) ps.push(c[i]); } p = (Coordinate) ps.push(c[0]); return ps; }
[ "private", "Stack", "grahamScan", "(", "Coordinate", "[", "]", "c", ")", "{", "Coordinate", "p", ";", "Stack", "ps", "=", "new", "Stack", "(", ")", ";", "p", "=", "(", "Coordinate", ")", "ps", ".", "push", "(", "c", "[", "0", "]", ")", ";", "p"...
Uses the Graham Scan algorithm to compute the convex hull vertices. @param c a list of points, with at least 3 entries @return a Stack containing the ordered points of the convex hull ring
[ "Uses", "the", "Graham", "Scan", "algorithm", "to", "compute", "the", "convex", "hull", "vertices", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/mesh/FullConvexHull.java#L219-L238
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_Force3D.java
ST_Force3D.force3D
public static Geometry force3D(Geometry geom) { if (geom == null) { return null; } return GeometryCoordinateDimension.force(geom, 3); }
java
public static Geometry force3D(Geometry geom) { if (geom == null) { return null; } return GeometryCoordinateDimension.force(geom, 3); }
[ "public", "static", "Geometry", "force3D", "(", "Geometry", "geom", ")", "{", "if", "(", "geom", "==", "null", ")", "{", "return", "null", ";", "}", "return", "GeometryCoordinateDimension", ".", "force", "(", "geom", ",", "3", ")", ";", "}" ]
Converts a XY geometry to XYZ. If a geometry has no Z component, then a 0 Z coordinate is tacked on. @param geom @return
[ "Converts", "a", "XY", "geometry", "to", "XYZ", ".", "If", "a", "geometry", "has", "no", "Z", "component", "then", "a", "0", "Z", "coordinate", "is", "tacked", "on", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_Force3D.java#L54-L59
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/predicates/ST_DWithin.java
ST_DWithin.isWithinDistance
public static Boolean isWithinDistance(Geometry geomA, Geometry geomB, Double distance) { if(geomA == null||geomB == null){ return null; } return geomA.isWithinDistance(geomB, distance); }
java
public static Boolean isWithinDistance(Geometry geomA, Geometry geomB, Double distance) { if(geomA == null||geomB == null){ return null; } return geomA.isWithinDistance(geomB, distance); }
[ "public", "static", "Boolean", "isWithinDistance", "(", "Geometry", "geomA", ",", "Geometry", "geomB", ",", "Double", "distance", ")", "{", "if", "(", "geomA", "==", "null", "||", "geomB", "==", "null", ")", "{", "return", "null", ";", "}", "return", "ge...
Returns true if the geometries are within the specified distance of one another. @param geomA Geometry A @param geomB Geometry B @param distance Distance @return True if if the geometries are within the specified distance of one another
[ "Returns", "true", "if", "the", "geometries", "are", "within", "the", "specified", "distance", "of", "one", "another", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/predicates/ST_DWithin.java#L52-L57
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojson
public static String toGeojson(Geometry geom) { StringBuilder sb = new StringBuilder(); toGeojsonGeometry(geom, sb); return sb.toString(); }
java
public static String toGeojson(Geometry geom) { StringBuilder sb = new StringBuilder(); toGeojsonGeometry(geom, sb); return sb.toString(); }
[ "public", "static", "String", "toGeojson", "(", "Geometry", "geom", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "toGeojsonGeometry", "(", "geom", ",", "sb", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Convert the geometry to a GeoJSON representation. @param geom @return
[ "Convert", "the", "geometry", "to", "a", "GeoJSON", "representation", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L50-L54
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonGeometry
public static void toGeojsonGeometry(Geometry geom, StringBuilder sb) { if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } else if (geom instanceof MultiPoint) { toGeojsonMultiPoint((MultiPoint) geom, sb); } else if (geom instanceof MultiLineString) { toGeojsonMultiLineString((MultiLineString) geom, sb); } else if (geom instanceof MultiPolygon) { toGeojsonMultiPolygon((MultiPolygon) geom, sb); } else { toGeojsonGeometryCollection((GeometryCollection) geom, sb); } }
java
public static void toGeojsonGeometry(Geometry geom, StringBuilder sb) { if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } else if (geom instanceof MultiPoint) { toGeojsonMultiPoint((MultiPoint) geom, sb); } else if (geom instanceof MultiLineString) { toGeojsonMultiLineString((MultiLineString) geom, sb); } else if (geom instanceof MultiPolygon) { toGeojsonMultiPolygon((MultiPolygon) geom, sb); } else { toGeojsonGeometryCollection((GeometryCollection) geom, sb); } }
[ "public", "static", "void", "toGeojsonGeometry", "(", "Geometry", "geom", ",", "StringBuilder", "sb", ")", "{", "if", "(", "geom", "instanceof", "Point", ")", "{", "toGeojsonPoint", "(", "(", "Point", ")", "geom", ",", "sb", ")", ";", "}", "else", "if", ...
Transform a JTS geometry to a GeoJSON representation. @param geom @param sb
[ "Transform", "a", "JTS", "geometry", "to", "a", "GeoJSON", "representation", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L63-L79
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonPoint
public static void toGeojsonPoint(Point point, StringBuilder sb) { Coordinate coord = point.getCoordinate(); sb.append("{\"type\":\"Point\",\"coordinates\":["); sb.append(coord.x).append(",").append(coord.y); if (!Double.isNaN(coord.z)) { sb.append(",").append(coord.z); } sb.append("]}"); }
java
public static void toGeojsonPoint(Point point, StringBuilder sb) { Coordinate coord = point.getCoordinate(); sb.append("{\"type\":\"Point\",\"coordinates\":["); sb.append(coord.x).append(",").append(coord.y); if (!Double.isNaN(coord.z)) { sb.append(",").append(coord.z); } sb.append("]}"); }
[ "public", "static", "void", "toGeojsonPoint", "(", "Point", "point", ",", "StringBuilder", "sb", ")", "{", "Coordinate", "coord", "=", "point", ".", "getCoordinate", "(", ")", ";", "sb", ".", "append", "(", "\"{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[\"", ...
For type "Point", the "coordinates" member must be a single position. A position is the fundamental geometry construct. The "coordinates" member of a geometry object is composed of one position (in the case of a Point geometry), an array of positions (LineString or MultiPoint geometries), an array of arrays of positions (Polygons, MultiLineStrings), or a multidimensional array of positions (MultiPolygon). A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification. Syntax: { "type": "Point", "coordinates": [100.0, 0.0] } @param point @param sb
[ "For", "type", "Point", "the", "coordinates", "member", "must", "be", "a", "single", "position", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L106-L114
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonMultiPoint
public static void toGeojsonMultiPoint(MultiPoint multiPoint, StringBuilder sb) { sb.append("{\"type\":\"MultiPoint\",\"coordinates\":"); toGeojsonCoordinates(multiPoint.getCoordinates(), sb); sb.append("}"); }
java
public static void toGeojsonMultiPoint(MultiPoint multiPoint, StringBuilder sb) { sb.append("{\"type\":\"MultiPoint\",\"coordinates\":"); toGeojsonCoordinates(multiPoint.getCoordinates(), sb); sb.append("}"); }
[ "public", "static", "void", "toGeojsonMultiPoint", "(", "MultiPoint", "multiPoint", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"{\\\"type\\\":\\\"MultiPoint\\\",\\\"coordinates\\\":\"", ")", ";", "toGeojsonCoordinates", "(", "multiPoint", ".", "ge...
Coordinates of a MultiPoint are an array of positions. Syntax: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] } @param multiPoint @param sb
[ "Coordinates", "of", "a", "MultiPoint", "are", "an", "array", "of", "positions", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L126-L130
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonLineString
public static void toGeojsonLineString(LineString lineString, StringBuilder sb) { sb.append("{\"type\":\"LineString\",\"coordinates\":"); toGeojsonCoordinates(lineString.getCoordinates(), sb); sb.append("}"); }
java
public static void toGeojsonLineString(LineString lineString, StringBuilder sb) { sb.append("{\"type\":\"LineString\",\"coordinates\":"); toGeojsonCoordinates(lineString.getCoordinates(), sb); sb.append("}"); }
[ "public", "static", "void", "toGeojsonLineString", "(", "LineString", "lineString", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"{\\\"type\\\":\\\"LineString\\\",\\\"coordinates\\\":\"", ")", ";", "toGeojsonCoordinates", "(", "lineString", ".", "ge...
Coordinates of LineString are an array of positions. Syntax: { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] } @param lineString @param sb
[ "Coordinates", "of", "LineString", "are", "an", "array", "of", "positions", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L142-L146
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonMultiLineString
public static void toGeojsonMultiLineString(MultiLineString multiLineString, StringBuilder sb) { sb.append("{\"type\":\"MultiLineString\",\"coordinates\":["); for (int i = 0; i < multiLineString.getNumGeometries(); i++) { toGeojsonCoordinates(multiLineString.getGeometryN(i).getCoordinates(), sb); if (i < multiLineString.getNumGeometries() - 1) { sb.append(","); } } sb.append("]}"); }
java
public static void toGeojsonMultiLineString(MultiLineString multiLineString, StringBuilder sb) { sb.append("{\"type\":\"MultiLineString\",\"coordinates\":["); for (int i = 0; i < multiLineString.getNumGeometries(); i++) { toGeojsonCoordinates(multiLineString.getGeometryN(i).getCoordinates(), sb); if (i < multiLineString.getNumGeometries() - 1) { sb.append(","); } } sb.append("]}"); }
[ "public", "static", "void", "toGeojsonMultiLineString", "(", "MultiLineString", "multiLineString", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"{\\\"type\\\":\\\"MultiLineString\\\",\\\"coordinates\\\":[\"", ")", ";", "for", "(", "int", "i", "=", ...
Coordinates of a MultiLineString are an array of LineString coordinate arrays. Syntax: { "type": "MultiLineString", "coordinates": [ [ [100.0, 0.0], [101.0, 1.0] ], [ [102.0, 2.0], [103.0, 3.0] ] ] } @param multiLineString @param sb
[ "Coordinates", "of", "a", "MultiLineString", "are", "an", "array", "of", "LineString", "coordinate", "arrays", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L160-L169
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonMultiPolygon
public static void toGeojsonMultiPolygon(MultiPolygon multiPolygon, StringBuilder sb) { sb.append("{\"type\":\"MultiPolygon\",\"coordinates\":["); for (int i = 0; i < multiPolygon.getNumGeometries(); i++) { Polygon p = (Polygon) multiPolygon.getGeometryN(i); sb.append("["); //Process exterior ring toGeojsonCoordinates(p.getExteriorRing().getCoordinates(), sb); //Process interior rings for (int j = 0; j < p.getNumInteriorRing(); j++) { sb.append(","); toGeojsonCoordinates(p.getInteriorRingN(j).getCoordinates(), sb); } sb.append("]"); if (i < multiPolygon.getNumGeometries() - 1) { sb.append(","); } } sb.append("]}"); }
java
public static void toGeojsonMultiPolygon(MultiPolygon multiPolygon, StringBuilder sb) { sb.append("{\"type\":\"MultiPolygon\",\"coordinates\":["); for (int i = 0; i < multiPolygon.getNumGeometries(); i++) { Polygon p = (Polygon) multiPolygon.getGeometryN(i); sb.append("["); //Process exterior ring toGeojsonCoordinates(p.getExteriorRing().getCoordinates(), sb); //Process interior rings for (int j = 0; j < p.getNumInteriorRing(); j++) { sb.append(","); toGeojsonCoordinates(p.getInteriorRingN(j).getCoordinates(), sb); } sb.append("]"); if (i < multiPolygon.getNumGeometries() - 1) { sb.append(","); } } sb.append("]}"); }
[ "public", "static", "void", "toGeojsonMultiPolygon", "(", "MultiPolygon", "multiPolygon", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"{\\\"type\\\":\\\"MultiPolygon\\\",\\\"coordinates\\\":[\"", ")", ";", "for", "(", "int", "i", "=", "0", ";",...
Coordinates of a MultiPolygon are an array of Polygon coordinate arrays. Syntax: { "type": "MultiPolygon", "coordinates": [ [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]] ] } @param multiPolygon @param sb
[ "Coordinates", "of", "a", "MultiPolygon", "are", "an", "array", "of", "Polygon", "coordinate", "arrays", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L218-L237
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonGeometryCollection
public static void toGeojsonGeometryCollection(GeometryCollection geometryCollection, StringBuilder sb) { sb.append("{\"type\":\"GeometryCollection\",\"geometries\":["); for (int i = 0; i < geometryCollection.getNumGeometries(); i++) { Geometry geom = geometryCollection.getGeometryN(i); if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } if (i < geometryCollection.getNumGeometries() - 1) { sb.append(","); } } sb.append("]}"); }
java
public static void toGeojsonGeometryCollection(GeometryCollection geometryCollection, StringBuilder sb) { sb.append("{\"type\":\"GeometryCollection\",\"geometries\":["); for (int i = 0; i < geometryCollection.getNumGeometries(); i++) { Geometry geom = geometryCollection.getGeometryN(i); if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } if (i < geometryCollection.getNumGeometries() - 1) { sb.append(","); } } sb.append("]}"); }
[ "public", "static", "void", "toGeojsonGeometryCollection", "(", "GeometryCollection", "geometryCollection", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"{\\\"type\\\":\\\"GeometryCollection\\\",\\\"geometries\\\":[\"", ")", ";", "for", "(", "int", "i...
A GeoJSON object with type "GeometryCollection" is a geometry object which represents a collection of geometry objects. A geometry collection must have a member with the name "geometries". The value corresponding to "geometries"is an array. Each element in this array is a GeoJSON geometry object. Syntax: { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ] } @param geometryCollection @param sb
[ "A", "GeoJSON", "object", "with", "type", "GeometryCollection", "is", "a", "geometry", "object", "which", "represents", "a", "collection", "of", "geometry", "objects", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L256-L272
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonCoordinates
public static void toGeojsonCoordinates(Coordinate[] coords, StringBuilder sb) { sb.append("["); for (int i = 0; i < coords.length; i++) { toGeojsonCoordinate(coords[i], sb); if (i < coords.length - 1) { sb.append(","); } } sb.append("]"); }
java
public static void toGeojsonCoordinates(Coordinate[] coords, StringBuilder sb) { sb.append("["); for (int i = 0; i < coords.length; i++) { toGeojsonCoordinate(coords[i], sb); if (i < coords.length - 1) { sb.append(","); } } sb.append("]"); }
[ "public", "static", "void", "toGeojsonCoordinates", "(", "Coordinate", "[", "]", "coords", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"[\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "coords", ".", "length", ";...
Convert a jts array of coordinates to a GeoJSON coordinates representation. Syntax: [[X1,Y1],[X2,Y2]] @param coords @param sb
[ "Convert", "a", "jts", "array", "of", "coordinates", "to", "a", "GeoJSON", "coordinates", "representation", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L285-L294
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeojsonCoordinate
public static void toGeojsonCoordinate(Coordinate coord, StringBuilder sb) { sb.append("["); sb.append(coord.x).append(",").append(coord.y); if (!Double.isNaN(coord.z)) { sb.append(",").append(coord.z); } sb.append("]"); }
java
public static void toGeojsonCoordinate(Coordinate coord, StringBuilder sb) { sb.append("["); sb.append(coord.x).append(",").append(coord.y); if (!Double.isNaN(coord.z)) { sb.append(",").append(coord.z); } sb.append("]"); }
[ "public", "static", "void", "toGeojsonCoordinate", "(", "Coordinate", "coord", ",", "StringBuilder", "sb", ")", "{", "sb", ".", "append", "(", "\"[\"", ")", ";", "sb", ".", "append", "(", "coord", ".", "x", ")", ".", "append", "(", "\",\"", ")", ".", ...
Convert a JTS coordinate to a GeoJSON representation. Only x, y and z values are supported. Syntax: [X,Y] or [X,Y,Z] @param coord @param sb
[ "Convert", "a", "JTS", "coordinate", "to", "a", "GeoJSON", "representation", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L308-L315
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java
ST_AsGeoJSON.toGeoJsonEnvelope
public String toGeoJsonEnvelope(Envelope e) { return new StringBuffer().append("[").append(e.getMinX()).append(",") .append(e.getMinY()).append(",").append(e.getMaxX()).append(",") .append(e.getMaxY()).append("]").toString(); }
java
public String toGeoJsonEnvelope(Envelope e) { return new StringBuffer().append("[").append(e.getMinX()).append(",") .append(e.getMinY()).append(",").append(e.getMaxX()).append(",") .append(e.getMaxY()).append("]").toString(); }
[ "public", "String", "toGeoJsonEnvelope", "(", "Envelope", "e", ")", "{", "return", "new", "StringBuffer", "(", ")", ".", "append", "(", "\"[\"", ")", ".", "append", "(", "e", ".", "getMinX", "(", ")", ")", ".", "append", "(", "\",\"", ")", ".", "appe...
Convert a JTS Envelope to a GeoJSON representation. @param e The envelope @return The envelope encoded as GeoJSON
[ "Convert", "a", "JTS", "Envelope", "to", "a", "GeoJSON", "representation", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L324-L328
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/osm/ST_OSMDownloader.java
ST_OSMDownloader.downloadOSMFile
public static void downloadOSMFile(File file, Envelope geometryEnvelope) throws IOException { HttpURLConnection urlCon = (HttpURLConnection) createOsmUrl(geometryEnvelope).openConnection(); urlCon.setRequestMethod("GET"); urlCon.connect(); switch (urlCon.getResponseCode()) { case 400: throw new IOException("Error : Cannot query the OSM API with the following bounding box"); case 509: throw new IOException("Error: You have downloaded too much data. Please try again later"); default: InputStream in = urlCon.getInputStream(); OutputStream out = new FileOutputStream(file); try { byte[] data = new byte[4096]; while (true) { int numBytes = in.read(data); if (numBytes == -1) { break; } out.write(data, 0, numBytes); } } finally { out.close(); in.close(); } break; } }
java
public static void downloadOSMFile(File file, Envelope geometryEnvelope) throws IOException { HttpURLConnection urlCon = (HttpURLConnection) createOsmUrl(geometryEnvelope).openConnection(); urlCon.setRequestMethod("GET"); urlCon.connect(); switch (urlCon.getResponseCode()) { case 400: throw new IOException("Error : Cannot query the OSM API with the following bounding box"); case 509: throw new IOException("Error: You have downloaded too much data. Please try again later"); default: InputStream in = urlCon.getInputStream(); OutputStream out = new FileOutputStream(file); try { byte[] data = new byte[4096]; while (true) { int numBytes = in.read(data); if (numBytes == -1) { break; } out.write(data, 0, numBytes); } } finally { out.close(); in.close(); } break; } }
[ "public", "static", "void", "downloadOSMFile", "(", "File", "file", ",", "Envelope", "geometryEnvelope", ")", "throws", "IOException", "{", "HttpURLConnection", "urlCon", "=", "(", "HttpURLConnection", ")", "createOsmUrl", "(", "geometryEnvelope", ")", ".", "openCon...
Download OSM file from the official server @param file @param geometryEnvelope @throws IOException
[ "Download", "OSM", "file", "from", "the", "official", "server" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/osm/ST_OSMDownloader.java#L116-L142
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/osm/ST_OSMDownloader.java
ST_OSMDownloader.createOsmUrl
private static URL createOsmUrl(Envelope geometryEnvelope) { try { return new URL(OSM_API_URL + "map?bbox=" + geometryEnvelope.getMinX() + "," + geometryEnvelope.getMinY() + "," + geometryEnvelope.getMaxX() + "," + geometryEnvelope.getMaxY()); } catch (MalformedURLException e) { throw new IllegalStateException(e); } }
java
private static URL createOsmUrl(Envelope geometryEnvelope) { try { return new URL(OSM_API_URL + "map?bbox=" + geometryEnvelope.getMinX() + "," + geometryEnvelope.getMinY() + "," + geometryEnvelope.getMaxX() + "," + geometryEnvelope.getMaxY()); } catch (MalformedURLException e) { throw new IllegalStateException(e); } }
[ "private", "static", "URL", "createOsmUrl", "(", "Envelope", "geometryEnvelope", ")", "{", "try", "{", "return", "new", "URL", "(", "OSM_API_URL", "+", "\"map?bbox=\"", "+", "geometryEnvelope", ".", "getMinX", "(", ")", "+", "\",\"", "+", "geometryEnvelope", "...
Build the OSM URL based on a given envelope @param geometryEnvelope @return
[ "Build", "the", "OSM", "URL", "based", "on", "a", "given", "envelope" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/osm/ST_OSMDownloader.java#L150-L158
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/predicates/ST_Disjoint.java
ST_Disjoint.geomDisjoint
public static Boolean geomDisjoint(Geometry a, Geometry b) { if(a==null || b==null) { return null; } return a.disjoint(b); }
java
public static Boolean geomDisjoint(Geometry a, Geometry b) { if(a==null || b==null) { return null; } return a.disjoint(b); }
[ "public", "static", "Boolean", "geomDisjoint", "(", "Geometry", "a", ",", "Geometry", "b", ")", "{", "if", "(", "a", "==", "null", "||", "b", "==", "null", ")", "{", "return", "null", ";", "}", "return", "a", ".", "disjoint", "(", "b", ")", ";", ...
Return true if the two Geometries are disjoint @param a Geometry Geometry. @param b Geometry instance @return true if the two Geometries are disjoint
[ "Return", "true", "if", "the", "two", "Geometries", "are", "disjoint" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/predicates/ST_Disjoint.java#L52-L57
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/kml/KMLWriterDriver.java
KMLWriterDriver.write
public void write(ProgressVisitor progress) throws SQLException { if (FileUtil.isExtensionWellFormated(fileName, "kml")) { writeKML(progress); } else if (FileUtil.isExtensionWellFormated(fileName, "kmz")) { String name = fileName.getName(); int pos = name.lastIndexOf("."); writeKMZ(progress, name.substring(0, pos) + ".kml"); } else { throw new SQLException("Please use the extensions .kml or kmz."); } }
java
public void write(ProgressVisitor progress) throws SQLException { if (FileUtil.isExtensionWellFormated(fileName, "kml")) { writeKML(progress); } else if (FileUtil.isExtensionWellFormated(fileName, "kmz")) { String name = fileName.getName(); int pos = name.lastIndexOf("."); writeKMZ(progress, name.substring(0, pos) + ".kml"); } else { throw new SQLException("Please use the extensions .kml or kmz."); } }
[ "public", "void", "write", "(", "ProgressVisitor", "progress", ")", "throws", "SQLException", "{", "if", "(", "FileUtil", ".", "isExtensionWellFormated", "(", "fileName", ",", "\"kml\"", ")", ")", "{", "writeKML", "(", "progress", ")", ";", "}", "else", "if"...
Write spatial table to kml or kmz file format. @param progress @throws SQLException
[ "Write", "spatial", "table", "to", "kml", "or", "kmz", "file", "format", "." ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/kml/KMLWriterDriver.java#L65-L75
train
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/kml/KMLWriterDriver.java
KMLWriterDriver.writeKML
private void writeKML(ProgressVisitor progress) throws SQLException { FileOutputStream fos = null; try { fos = new FileOutputStream(fileName); writeKMLDocument(progress, fos); } catch (FileNotFoundException ex) { throw new SQLException(ex); } finally { try { if (fos != null) { fos.close(); } } catch (IOException ex) { throw new SQLException(ex); } } }
java
private void writeKML(ProgressVisitor progress) throws SQLException { FileOutputStream fos = null; try { fos = new FileOutputStream(fileName); writeKMLDocument(progress, fos); } catch (FileNotFoundException ex) { throw new SQLException(ex); } finally { try { if (fos != null) { fos.close(); } } catch (IOException ex) { throw new SQLException(ex); } } }
[ "private", "void", "writeKML", "(", "ProgressVisitor", "progress", ")", "throws", "SQLException", "{", "FileOutputStream", "fos", "=", "null", ";", "try", "{", "fos", "=", "new", "FileOutputStream", "(", "fileName", ")", ";", "writeKMLDocument", "(", "progress",...
Write the spatial table to a KML format @param progress @throws SQLException
[ "Write", "the", "spatial", "table", "to", "a", "KML", "format" ]
9cd70b447e6469cecbc2fc64b16774b59491df3b
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/kml/KMLWriterDriver.java#L83-L100
train