idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
6,000 | 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 ( "[" ) ; toGeojsonCoo... | Coordinates of a MultiPolygon are an array of Polygon coordinate arrays . |
6,001 | 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 ( ge... | A GeoJSON object with type GeometryCollection is a geometry object which represents a collection of geometry objects . |
6,002 | 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 ( "]" ) ; } | Convert a jts array of coordinates to a GeoJSON coordinates representation . |
6,003 | 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 ( "]" ) ; } | Convert a JTS coordinate to a GeoJSON representation . |
6,004 | 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 ( ) ; } | Convert a JTS Envelope to a GeoJSON representation . |
6,005 | 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 : th... | Download OSM file from the official server |
6,006 | 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 Illeg... | Build the OSM URL based on a given envelope |
6,007 | 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 |
6,008 | 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 ( p... | Write spatial table to kml or kmz file format . |
6,009 | 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 ( ) ; } }... | Write the spatial table to a KML format |
6,010 | private void writeKMZ ( ProgressVisitor progress , String fileNameWithExtension ) throws SQLException { ZipOutputStream zos = null ; try { zos = new ZipOutputStream ( new FileOutputStream ( fileName ) ) ; zos . putNextEntry ( new ZipEntry ( fileNameWithExtension ) ) ; writeKMLDocument ( progress , zos ) ; } catch ( Fil... | Write the spatial table to a KMZ format |
6,011 | private void writeKMLDocument ( ProgressVisitor progress , OutputStream outputStream ) throws SQLException { List < String > spatialFieldNames = SFSUtilities . getGeometryFields ( connection , TableLocation . parse ( tableName , JDBCUtilities . isH2DataBase ( connection . getMetaData ( ) ) ) ) ; if ( spatialFieldNames ... | Write the KML document Note the document stores only the first geometry column in the placeMark element . The other geomtry columns are ignored . |
6,012 | public void writePlacemark ( XMLStreamWriter xmlOut , ResultSet rs , int geoFieldIndex , String spatialFieldName ) throws XMLStreamException , SQLException { xmlOut . writeStartElement ( "Placemark" ) ; if ( columnCount > 1 ) { writeExtendedData ( xmlOut , rs ) ; } StringBuilder sb = new StringBuilder ( ) ; Geometry ge... | A Placemark is a Feature with associated Geometry . |
6,013 | private static String getKMLType ( int sqlTypeId , String sqlTypeName ) throws SQLException { switch ( sqlTypeId ) { case Types . BOOLEAN : return "bool" ; case Types . DOUBLE : return "double" ; case Types . FLOAT : return "float" ; case Types . INTEGER : case Types . BIGINT : return "int" ; case Types . SMALLINT : re... | Return the kml type representation from SQL data type |
6,014 | public static Boolean geomTouches ( Geometry a , Geometry b ) { if ( a == null || b == null ) { return null ; } return a . touches ( b ) ; } | Return true if the geometry A touches the geometry B |
6,015 | public static Geometry removeCoordinates ( Geometry geom ) { if ( geom == null ) { return null ; } else if ( geom . isEmpty ( ) ) { return geom ; } else if ( geom instanceof Point ) { return geom ; } else if ( geom instanceof MultiPoint ) { return removeCoordinates ( ( MultiPoint ) geom ) ; } else if ( geom instanceof ... | Removes duplicated coordinates within a geometry . |
6,016 | public static MultiPoint removeCoordinates ( MultiPoint g ) { Coordinate [ ] coords = CoordinateUtils . removeDuplicatedCoordinates ( g . getCoordinates ( ) , false ) ; return FACTORY . createMultiPoint ( coords ) ; } | Removes duplicated coordinates within a MultiPoint . |
6,017 | public static void writeKML ( Connection connection , String fileName , String tableReference ) throws SQLException , IOException { KMLDriverFunction kMLDriverFunction = new KMLDriverFunction ( ) ; kMLDriverFunction . exportTable ( connection , tableReference , URIUtilities . fileFromString ( fileName ) , new EmptyProg... | This method is used to write a spatial table into a KML file |
6,018 | public static GeometryLocation getVertexToSnap ( Geometry g , Point p , double tolerance ) { DistanceOp distanceOp = new DistanceOp ( g , p ) ; GeometryLocation snapedPoint = distanceOp . nearestLocations ( ) [ 0 ] ; if ( tolerance == 0 || snapedPoint . getCoordinate ( ) . distance ( p . getCoordinate ( ) ) <= toleranc... | Gets the coordinate of a Geometry that is the nearest of a given Point with a distance tolerance . |
6,019 | public static Geometry computeBoundingCircle ( Geometry geometry ) { if ( geometry == null ) { return null ; } return new MinimumBoundingCircle ( geometry ) . getCircle ( ) ; } | Computes the bounding circle |
6,020 | public void write ( Object [ ] record ) throws IOException , DbaseFileException { if ( record . length != header . getNumFields ( ) ) { throw new DbaseFileException ( "Wrong number of fields " + record . length + " expected " + header . getNumFields ( ) ) ; } buffer . position ( 0 ) ; buffer . put ( ( byte ) ' ' ) ; fo... | Write a single dbase record . |
6,021 | public static Double getMaxX ( Geometry geom ) { if ( geom != null ) { return geom . getEnvelopeInternal ( ) . getMaxX ( ) ; } else { return null ; } } | Returns the maximal x - value of the given geometry . |
6,022 | public void put ( Geometry geom , MODE mode ) throws IllegalArgumentException { gf = geom . getFactory ( ) ; convertedInput = null ; int dimension ; if ( geom . getClass ( ) . getName ( ) . equals ( GeometryCollection . class . getName ( ) ) ) { dimension = getMinDimension ( ( GeometryCollection ) geom ) ; } else { dim... | Put a geometry into the data array . Set true to populate the list of points and edges needed for the ContrainedDelaunayTriangulation . Set false to populate only the list of points . Note the z - value is forced to O when it s equal to NaN . |
6,023 | public double get3DArea ( ) { if ( convertedInput != null ) { List < DelaunayTriangle > delaunayTriangle = convertedInput . getTriangles ( ) ; double sum = 0 ; for ( DelaunayTriangle triangle : delaunayTriangle ) { sum += computeTriangleArea3D ( triangle ) ; } return sum ; } else { return 0 ; } } | Return the 3D area of all triangles |
6,024 | private double computeTriangleArea3D ( DelaunayTriangle triangle ) { TriangulationPoint [ ] points = triangle . points ; TriangulationPoint p1 = points [ 0 ] ; TriangulationPoint p2 = points [ 1 ] ; TriangulationPoint p3 = points [ 2 ] ; double ux = p2 . getX ( ) - p1 . getX ( ) ; double uy = p2 . getY ( ) - p1 . getY ... | Computes the 3D area of a triangle . |
6,025 | private void addGeometry ( Geometry geom ) throws IllegalArgumentException { if ( ! geom . isValid ( ) ) { throw new IllegalArgumentException ( "Provided geometry is not valid !" ) ; } if ( geom instanceof GeometryCollection ) { Map < TriangulationPoint , Integer > pts = new HashMap < TriangulationPoint , Integer > ( g... | Add a geometry to the list of points and edges used by the triangulation . |
6,026 | public final void setAttribute ( String currentElement , StringBuilder contentBuffer ) { if ( currentElement . equalsIgnoreCase ( GPXTags . NAME ) ) { setName ( contentBuffer ) ; } else if ( currentElement . equalsIgnoreCase ( GPXTags . CMT ) ) { setCmt ( contentBuffer ) ; } else if ( currentElement . equalsIgnoreCase ... | Set an attribute for a line . The String currentElement gives the information of which attribute have to be setted . The attribute to set is given by the StringBuilder contentBuffer . |
6,027 | public final void setLink ( Attributes attributes ) { lineValues [ GpxMetadata . LINELINK_HREF ] = attributes . getValue ( GPXTags . HREF ) ; } | Set a link to additional information about the route or the track . |
6,028 | public final void setNumber ( StringBuilder contentBuffer ) { lineValues [ GpxMetadata . LINENUMBER ] = Integer . parseInt ( contentBuffer . toString ( ) ) ; } | Set the GPS number to additional information about the route or the track . |
6,029 | public static Geometry densify ( Geometry geometry , double tolerance ) { if ( geometry == null ) { return null ; } return Densifier . densify ( geometry , tolerance ) ; } | Densify a geometry using the given distance tolerance . |
6,030 | public static TableLocation parseInputTable ( Connection connection , String inputTable ) throws SQLException { return TableLocation . parse ( inputTable , JDBCUtilities . isH2DataBase ( connection . getMetaData ( ) ) ) ; } | Convert an input table String to a TableLocation |
6,031 | public static TableLocation suffixTableLocation ( TableLocation inputTable , String suffix ) { return new TableLocation ( inputTable . getCatalog ( ) , inputTable . getSchema ( ) , inputTable . getTable ( ) + suffix ) ; } | Suffix a TableLocation |
6,032 | public static String caseIdentifier ( TableLocation requestedTable , String tableName , boolean isH2 ) { return new TableLocation ( requestedTable . getCatalog ( ) , requestedTable . getSchema ( ) , TableLocation . parse ( tableName , isH2 ) . getTable ( ) ) . toString ( ) ; } | Return the table identifier in the best fit depending on database type |
6,033 | public static CoordinateSequenceDimensionFilter apply ( Geometry geometry ) { CoordinateSequenceDimensionFilter cd = new CoordinateSequenceDimensionFilter ( ) ; geometry . apply ( cd ) ; return cd ; } | Init CoordinateSequenceDimensionFilter object . |
6,034 | public int removeColumn ( String inFieldName ) { int retCol = - 1 ; int tempLength = 1 ; DbaseField [ ] tempFieldDescriptors = new DbaseField [ fields . length - 1 ] ; for ( int i = 0 , j = 0 ; i < fields . length ; i ++ ) { if ( ! inFieldName . equalsIgnoreCase ( fields [ i ] . fieldName . trim ( ) ) ) { if ( i == j &... | Remove a column from this DbaseFileHeader . |
6,035 | public boolean setEncoding ( String encoding ) { for ( Map . Entry < Byte , String > entry : CODE_PAGE_ENCODING . entrySet ( ) ) { if ( entry . getValue ( ) . equalsIgnoreCase ( encoding ) ) { this . fileEncoding = entry . getValue ( ) ; return true ; } } return false ; } | Set file encoding |
6,036 | public void writeHeader ( WritableByteChannel out ) throws IOException { if ( headerLength == - 1 ) { headerLength = MINIMUM_HEADER ; } ByteBuffer buffer = ByteBuffer . allocateDirect ( headerLength ) ; buffer . order ( ByteOrder . LITTLE_ENDIAN ) ; buffer . put ( MAGIC ) ; Calendar c = Calendar . getInstance ( ) ; c .... | Write the header data to the DBF file . |
6,037 | public static Double getMaxZ ( Geometry geom ) { if ( geom != null ) { return CoordinateUtils . zMinMax ( geom . getCoordinates ( ) ) [ 1 ] ; } else { return null ; } } | Returns the maximal z - value of the given geometry . |
6,038 | public void exportTable ( Connection connection , String tableReference , File fileName , ProgressVisitor progress , String encoding ) throws SQLException , IOException { final boolean isH2 = JDBCUtilities . isH2DataBase ( connection . getMetaData ( ) ) ; String regex = ".*(?i)\\b(select|from)\\b.*" ; Pattern pattern =... | Save a table or a query to a shpfile |
6,039 | private int doExport ( String tableReference , List < String > spatialFieldNames , ResultSet rs , int recordCount , File fileName , ProgressVisitor progress , String encoding ) throws SQLException , IOException { if ( spatialFieldNames . isEmpty ( ) ) { throw new SQLException ( String . format ( "The table or the query... | Method to export a resulset into a shapefile |
6,040 | private static ShapeType getShapeTypeFromGeometryMetaData ( GeometryMetaData meta ) throws SQLException { ShapeType shapeType ; switch ( meta . geometryType ) { case GeometryTypeCodes . MULTILINESTRING : case GeometryTypeCodes . LINESTRING : case GeometryTypeCodes . MULTILINESTRINGM : case GeometryTypeCodes . LINESTRIN... | Return the shape type supported by the shapefile format |
6,041 | private void parseGeoJson ( ProgressVisitor progress ) throws SQLException , IOException { this . progress = progress . subProcess ( 100 ) ; init ( ) ; if ( parseMetadata ( ) ) { GF = new GeometryFactory ( new PrecisionModel ( ) , parsedSRID ) ; parseData ( ) ; setGeometryTypeConstraints ( ) ; } else { throw new SQLExc... | Parses a GeoJSON 1 . 0 file and writes it to a table . |
6,042 | private boolean parseMetadata ( ) throws SQLException , IOException { FileInputStream fis = null ; try { fis = new FileInputStream ( fileName ) ; this . fc = fis . getChannel ( ) ; this . fileSize = fc . size ( ) ; readFileSizeEachNode = Math . max ( 1 , ( this . fileSize / AVERAGE_NODE_SIZE ) / 100 ) ; nodeCountProgre... | Parses the all GeoJSON feature to create the PreparedStatement . |
6,043 | private void parseFeaturesMetadata ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; while ( ! jp . getText ( ) . equalsIgnoreCase ( GeoJsonField . FEATURES ) && ! jp . getText ( ) . equalsIgnoreCase ( GeoJsonField . CRS ) ) { jp . nextToken ( ) ; if ( jp . getCurrentToken ( ) . equals ( JsonTo... | Parses the featureCollection to collect the field properties |
6,044 | private void parseFeatureMetadata ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; String field = jp . getText ( ) ; while ( ! field . equalsIgnoreCase ( GeoJsonField . GEOMETRY ) && ! field . equalsIgnoreCase ( GeoJsonField . PROPERTIES ) && ! jp . getCurrentToken ( ) . equals ( JsonToken . E... | Features in GeoJSON contain a geometry object and additional properties This method is used to collect metadata |
6,045 | private void parseParentGeometryMetadata ( JsonParser jp ) throws IOException , SQLException { if ( jp . nextToken ( ) != JsonToken . VALUE_NULL ) { jp . nextToken ( ) ; jp . nextToken ( ) ; String geometryType = jp . getText ( ) ; parseGeometryMetadata ( jp , geometryType ) ; } } | Parses the geometries to return its properties |
6,046 | private void parseGeometryMetadata ( JsonParser jp , String geometryType ) throws IOException , SQLException { if ( geometryType . equalsIgnoreCase ( GeoJsonField . POINT ) ) { parsePointMetadata ( jp ) ; finalGeometryTypes . add ( GeoJsonField . POINT ) ; } else if ( geometryType . equalsIgnoreCase ( GeoJsonField . MU... | Parses a all type of geometries and check if the geojson is wellformed . |
6,047 | private void parsePointMetadata ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; String coordinatesField = jp . getText ( ) ; if ( coordinatesField . equalsIgnoreCase ( GeoJsonField . COORDINATES ) ) { jp . nextToken ( ) ; parseCoordinateMetadata ( jp ) ; } else { throw new SQLException ( "Mal... | Parses a point and check if it s wellformated |
6,048 | private void parseCoordinateMetadata ( JsonParser jp ) throws IOException { jp . nextToken ( ) ; jp . nextToken ( ) ; jp . nextToken ( ) ; if ( jp . getCurrentToken ( ) != JsonToken . END_ARRAY ) { jp . nextToken ( ) ; } jp . nextToken ( ) ; } | Parses a GeoJSON coordinate array and check if it s wellformed . The first token corresponds to the first X value . The last token correponds to the end of the coordinate array ] . |
6,049 | private void init ( ) { 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 ) ; } | Creates the JsonFactory . |
6,050 | private Object [ ] parseFeature ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; String field = jp . getText ( ) ; while ( ! field . equalsIgnoreCase ( GeoJsonField . GEOMETRY ) && ! field . equalsIgnoreCase ( GeoJsonField . PROPERTIES ) && ! jp . getCurrentToken ( ) . equals ( JsonToken . END... | Features in GeoJSON contain a geometry object and additional properties This method returns all values stored in a feature . |
6,051 | private void parseFeatures ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; while ( ! jp . getText ( ) . equalsIgnoreCase ( GeoJsonField . FEATURES ) && ! jp . getText ( ) . equalsIgnoreCase ( GeoJsonField . CRS ) ) { jp . nextToken ( ) ; if ( jp . getCurrentToken ( ) . equals ( JsonToken . ST... | Parses the featureCollection |
6,052 | private void parseData ( ) throws IOException , SQLException { FileInputStream fis = null ; try { fis = new FileInputStream ( fileName ) ; try ( JsonParser jp = jsFactory . createParser ( fis ) ) { jp . nextToken ( ) ; jp . nextToken ( ) ; jp . nextToken ( ) ; String geomType = jp . getText ( ) ; if ( geomType . equals... | Parses the GeoJSON data and set the values to the table . |
6,053 | private int readCRS ( JsonParser jp ) throws IOException , SQLException { int srid = 0 ; jp . nextToken ( ) ; jp . nextToken ( ) ; jp . nextToken ( ) ; String firstField = jp . getText ( ) ; if ( firstField . equalsIgnoreCase ( GeoJsonField . NAME ) ) { jp . nextToken ( ) ; jp . nextToken ( ) ; jp . nextToken ( ) ; jp ... | Reads the CRS element and return the database SRID . |
6,054 | private String skipCRS ( JsonParser jp ) throws IOException { jp . nextToken ( ) ; jp . skipChildren ( ) ; jp . nextToken ( ) ; return jp . getText ( ) ; } | We skip the CRS because it has been already parsed . |
6,055 | private void setGeometryTypeConstraints ( ) throws SQLException { String finalGeometryType = GeoJsonField . GEOMETRY ; if ( finalGeometryTypes . size ( ) == 1 ) { finalGeometryType = ( String ) finalGeometryTypes . iterator ( ) . next ( ) ; } if ( isH2 ) { finalGeometryType = GeoJsonField . GEOMETRY ; connection . crea... | Adds the geometry type constraint and the SRID |
6,056 | public static Geometry split ( Geometry geomA , Geometry geomB , double tolerance ) throws SQLException { if ( geomA instanceof Polygon ) { throw new SQLException ( "Split a Polygon by a line is not supported using a tolerance. \n" + "Please used ST_Split(geom1, geom2)" ) ; } else if ( geomA instanceof LineString ) { i... | Split a geometry a according a geometry b using a snapping tolerance . |
6,057 | private static MultiLineString splitLineWithPoint ( LineString line , Point pointToSplit , double tolerance ) { return FACTORY . createMultiLineString ( splitLineStringWithPoint ( line , pointToSplit , tolerance ) ) ; } | Split a linestring with a point The point must be on the linestring |
6,058 | private static LineString [ ] splitLineStringWithPoint ( LineString line , Point pointToSplit , double tolerance ) { Coordinate [ ] coords = line . getCoordinates ( ) ; Coordinate firstCoord = coords [ 0 ] ; Coordinate lastCoord = coords [ coords . length - 1 ] ; Coordinate coordToSplit = pointToSplit . getCoordinate (... | Splits a LineString using a Point with a distance tolerance . |
6,059 | private static MultiLineString splitMultiLineStringWithPoint ( MultiLineString multiLineString , Point pointToSplit , double tolerance ) { ArrayList < LineString > linestrings = new ArrayList < LineString > ( ) ; boolean notChanged = true ; int nb = multiLineString . getNumGeometries ( ) ; for ( int i = 0 ; i < nb ; i ... | Splits a MultilineString using a point . |
6,060 | private static Collection < Polygon > splitPolygonizer ( Polygon polygon , LineString lineString ) throws SQLException { LinkedList < LineString > result = new LinkedList < LineString > ( ) ; ST_ToMultiSegments . createSegments ( polygon . getExteriorRing ( ) , result ) ; result . add ( lineString ) ; int holes = polyg... | Splits a Polygon with a LineString . |
6,061 | private static Geometry splitMultiPolygonWithLine ( MultiPolygon multiPolygon , LineString lineString ) throws SQLException { ArrayList < Polygon > allPolygons = new ArrayList < Polygon > ( ) ; for ( int i = 0 ; i < multiPolygon . getNumGeometries ( ) ; i ++ ) { Collection < Polygon > polygons = splitPolygonizer ( ( Po... | Splits a MultiPolygon using a LineString . |
6,062 | private static Geometry splitMultiLineStringWithLine ( MultiLineString input , LineString cut ) { Geometry lines = input . difference ( cut ) ; if ( lines instanceof LineString ) { return FACTORY . createMultiLineString ( new LineString [ ] { ( LineString ) lines . getGeometryN ( 0 ) } ) ; } return lines ; } | Splits the specified MultiLineString with another lineString . |
6,063 | public static Integer getHoles ( Geometry g ) { if ( g == null ) { return null ; } if ( g instanceof MultiPolygon ) { Polygon p = ( Polygon ) g . getGeometryN ( 0 ) ; if ( p != null ) { return p . getNumInteriorRing ( ) ; } } else if ( g instanceof Polygon ) { return ( ( Polygon ) g ) . getNumInteriorRing ( ) ; } retur... | Return the number of holes in a Polygon or MultiPolygon |
6,064 | private void checkOSMTables ( Connection connection , boolean isH2 , TableLocation requestedTable , String osmTableName ) throws SQLException { String [ ] omsTables = new String [ ] { OSMTablesFactory . TAG , OSMTablesFactory . NODE , OSMTablesFactory . NODE_TAG , OSMTablesFactory . WAY , OSMTablesFactory . WAY_NODE , ... | Check if one table already exists |
6,065 | private void createOSMDatabaseModel ( Connection connection , boolean isH2 , TableLocation requestedTable , String osmTableName ) throws SQLException { String tagTableName = TableUtilities . caseIdentifier ( requestedTable , osmTableName + OSMTablesFactory . TAG , isH2 ) ; tagPreparedStmt = OSMTablesFactory . createTag... | Create the OMS data model to store the content of the file |
6,066 | private static List < SegmentString > fixSegments ( List < SegmentString > segments ) { MCIndexNoder mCIndexNoder = new MCIndexNoder ( ) ; RobustLineIntersector robustLineIntersector = new RobustLineIntersector ( ) ; mCIndexNoder . setSegmentIntersector ( new IntersectionAdder ( robustLineIntersector ) ) ; mCIndexNoder... | Split originalSegments that intersects . Run this method after calling the last addSegment before calling getIsoVist |
6,067 | public void addSegment ( Coordinate p0 , Coordinate p1 ) { if ( p0 . distance ( p1 ) < epsilon ) { return ; } addSegment ( originalSegments , p0 , p1 ) ; } | Add occlusion segment in isovist |
6,068 | public void addGeometry ( Geometry geometry ) { if ( geometry instanceof LineString ) { addLineString ( originalSegments , ( LineString ) geometry ) ; } else if ( geometry instanceof Polygon ) { addPolygon ( originalSegments , ( Polygon ) geometry ) ; } else if ( geometry instanceof GeometryCollection ) { addGeometry (... | Explode geometry and add occlusion segments in isovist |
6,069 | public static String geth2gisVersion ( ) { try ( InputStream fs = H2GISFunctions . class . getResourceAsStream ( "/org/h2gis/functions/system/version.txt" ) ) { BufferedReader bufRead = new BufferedReader ( new InputStreamReader ( fs ) ) ; StringBuilder builder = new StringBuilder ( ) ; String line = null ; while ( ( l... | Return the H2GIS version available in the version txt file Otherwise return unknown |
6,070 | private static void firstFirstLastLast ( Statement st , TableLocation tableName , String pkCol , String geomCol , double tolerance ) throws SQLException { LOGGER . info ( "Selecting the first coordinate of the first geometry and " + "the last coordinate of the last geometry..." ) ; final String numGeoms = "ST_NumGeomet... | Return the first and last coordinates table |
6,071 | private static void makeEnvelopes ( Statement st , double tolerance , boolean isH2 , int srid ) throws SQLException { st . execute ( "DROP TABLE IF EXISTS" + PTS_TABLE + ";" ) ; if ( tolerance > 0 ) { LOGGER . info ( "Calculating envelopes around coordinates..." ) ; if ( isH2 ) { st . execute ( "CREATE TABLE " + PTS_T... | Make a big table of all points in the coords table with an envelope around each point . We will use this table to remove duplicate points . |
6,072 | private static void nodesTable ( Statement st , TableLocation nodesName , double tolerance , boolean isH2 , int srid ) throws SQLException { LOGGER . info ( "Creating the nodes table..." ) ; if ( tolerance > 0 ) { if ( isH2 ) { st . execute ( "CREATE TABLE " + nodesName + "(" + "NODE_ID SERIAL PRIMARY KEY, " + "THE_GEO... | Create the nodes table . |
6,073 | private static void edgesTable ( Statement st , TableLocation nodesName , TableLocation edgesName , double tolerance , boolean isH2 ) throws SQLException { LOGGER . info ( "Creating the edges table..." ) ; if ( tolerance > 0 ) { if ( isH2 ) { st . execute ( "CREATE SPATIAL INDEX ON " + nodesName + "(EXP);" ) ; st . exe... | Create the edges table . |
6,074 | public static double [ ] zMinMax ( final Coordinate [ ] cs ) { double zmin ; double zmax ; boolean validZFound = false ; double [ ] result = new double [ 2 ] ; zmin = Double . NaN ; zmax = Double . NaN ; double z ; for ( int t = cs . length - 1 ; t >= 0 ; t -- ) { z = cs [ t ] . z ; if ( ! ( Double . isNaN ( z ) ) ) { ... | Determine the min and max z values in an array of Coordinates . |
6,075 | public static boolean contains2D ( Coordinate [ ] coords , Coordinate coord ) { for ( Coordinate coordinate : coords ) { if ( coordinate . equals2D ( coord ) ) { return true ; } } return false ; } | Checks if a coordinate array contains a specific coordinate . |
6,076 | public static Coordinate vectorIntersection ( Coordinate p1 , Vector3D v1 , Coordinate p2 , Vector3D v2 ) { double delta ; Coordinate i = null ; delta = v1 . getX ( ) * ( - v2 . getY ( ) ) - ( - v1 . getY ( ) ) * v2 . getX ( ) ; if ( delta != 0 ) { double k = ( ( p2 . x - p1 . x ) * ( - v2 . getY ( ) ) - ( p2 . y - p1 ... | Compute intersection point of two vectors |
6,077 | public static Coordinate [ ] removeRepeatedCoordinates ( Coordinate [ ] coords , double tolerance , boolean duplicateFirstLast ) { ArrayList < Coordinate > finalCoords = new ArrayList < Coordinate > ( ) ; Coordinate prevCoord = coords [ 0 ] ; finalCoords . add ( prevCoord ) ; Coordinate firstCoord = prevCoord ; int nbC... | Remove repeated coordinates according a given tolerance |
6,078 | public void exportTable ( Connection connection , String tableReference , File fileName , ProgressVisitor progress , String encoding ) throws SQLException , IOException { String regex = ".*(?i)\\b(select|from)\\b.*" ; Pattern pattern = Pattern . compile ( regex ) ; Matcher matcher = pattern . matcher ( tableReference )... | Export a table or a query to as TSV file |
6,079 | public void exportFromResultSet ( Connection connection , ResultSet res , File fileName , ProgressVisitor progress , String encoding ) throws SQLException { Csv csv = new Csv ( ) ; String csvOptions = "charset=UTF-8 fieldSeparator=\t fieldDelimiter=\t" ; if ( encoding != null ) { csvOptions = String . format ( "charset... | Export a resultset to a TSV file |
6,080 | public static String generateLink ( Geometry geom , boolean withMarker ) { if ( geom == null ) { return null ; } Envelope env = geom . getEnvelopeInternal ( ) ; StringBuilder sb = new StringBuilder ( "http://www.openstreetmap.org/?" ) ; sb . append ( "minlon=" ) . append ( env . getMinX ( ) ) ; sb . append ( "&minlat="... | Create the OSM map link based on the bounding box of the geometry . |
6,081 | public static Polygon makePolygon ( Geometry shell ) throws IllegalArgumentException { if ( shell == null ) { return null ; } LinearRing outerLine = checkLineString ( shell ) ; return shell . getFactory ( ) . createPolygon ( outerLine , null ) ; } | Creates a Polygon formed by the given shell . |
6,082 | public static Polygon makePolygon ( Geometry shell , Geometry ... holes ) throws IllegalArgumentException { if ( shell == null ) { return null ; } LinearRing outerLine = checkLineString ( shell ) ; LinearRing [ ] interiorlinestrings = new LinearRing [ holes . length ] ; for ( int i = 0 ; i < holes . length ; i ++ ) { i... | Creates a Polygon formed by the given shell and holes . |
6,083 | private static LinearRing checkLineString ( Geometry geometry ) throws IllegalArgumentException { if ( geometry instanceof LinearRing ) { return ( LinearRing ) geometry ; } else if ( geometry instanceof LineString ) { LineString lineString = ( LineString ) geometry ; if ( lineString . isClosed ( ) ) { return geometry .... | Check if a geometry is a linestring and if its closed . |
6,084 | public static Geometry ST_Transform ( Connection connection , Geometry geom , Integer codeEpsg ) throws SQLException , CoordinateOperationException { if ( geom == null ) { return null ; } if ( codeEpsg == null ) { throw new IllegalArgumentException ( "The SRID code cannot be null." ) ; } if ( crsf == null ) { crsf = ne... | Returns a new geometry transformed to the SRID referenced by the integer parameter available in the spatial_ref_sys table |
6,085 | public static Geometry node ( Geometry geom ) { if ( geom == null ) { return null ; } Noder noder = new MCIndexNoder ( new IntersectionAdder ( new RobustLineIntersector ( ) ) ) ; noder . computeNodes ( SegmentStringUtil . extractNodedSegmentStrings ( geom ) ) ; return SegmentStringUtil . toGeometry ( noder . getNodedSu... | Nodes a geometry using a monotone chain and a spatial index |
6,086 | public void initialise ( XMLReader reader , AbstractGpxParserDefault parent ) { setReader ( reader ) ; setParent ( parent ) ; setContentBuffer ( parent . getContentBuffer ( ) ) ; setWptPreparedStmt ( parent . getWptPreparedStmt ( ) ) ; setElementNames ( parent . getElementNames ( ) ) ; setCurrentPoint ( parent . getCur... | Create a new specific parser . It has in memory the default parser the contentBuffer the elementNames and the currentPoint . |
6,087 | public void startElement ( String uri , String localName , String qName , Attributes attributes ) throws SAXException { getContentBuffer ( ) . delete ( 0 , getContentBuffer ( ) . length ( ) ) ; getElementNames ( ) . push ( qName ) ; } | Fires whenever an XML start markup is encountered . |
6,088 | public static Geometry removeRepeatedPoints ( Geometry geometry ) throws SQLException , SQLException , SQLException , SQLException { return removeDuplicateCoordinates ( geometry , 0 ) ; } | Returns a version of the given geometry with duplicated points removed . |
6,089 | public static Geometry removeDuplicateCoordinates ( Geometry geom , double tolerance ) throws SQLException { if ( geom == null ) { return null ; } else if ( geom . isEmpty ( ) ) { return geom ; } else if ( geom instanceof Point ) { return geom ; } else if ( geom instanceof MultiPoint ) { return geom ; } else if ( geom ... | Removes duplicated points within a geometry . |
6,090 | public static Connection openSpatialDataBase ( String dbName ) throws SQLException , ClassNotFoundException { String dbFilePath = getDataBasePath ( dbName ) ; String databasePath = "jdbc:h2:" + dbFilePath + H2_PARAMETERS ; org . h2 . Driver . load ( ) ; return DriverManager . getConnection ( databasePath , "sa" , "sa" ... | Open the connection to an existing database |
6,091 | private static String getDataBasePath ( String dbName ) { if ( dbName . startsWith ( "file://" ) ) { return new File ( URI . create ( dbName ) ) . getAbsolutePath ( ) ; } else { return new File ( "target/test-resources/dbH2" + dbName ) . getAbsolutePath ( ) ; } } | Return the path of the file database |
6,092 | public static Connection createSpatialDataBase ( String dbName , boolean initSpatial , String h2Parameters ) throws SQLException , ClassNotFoundException { String databasePath = initDBFile ( dbName , h2Parameters ) ; org . h2 . Driver . load ( ) ; Connection connection = DriverManager . getConnection ( databasePath , "... | Create a spatial database |
6,093 | public static Connection createSpatialDataBase ( String dbName , boolean initSpatial ) throws SQLException , ClassNotFoundException { return createSpatialDataBase ( dbName , initSpatial , H2_PARAMETERS ) ; } | Create a spatial database and register all H2GIS functions |
6,094 | public static Point closestPoint ( Geometry geomA , Geometry geomB ) { if ( geomA == null || geomB == null ) { return null ; } return geomA . getFactory ( ) . createPoint ( DistanceOp . nearestPoints ( geomA , geomB ) [ 0 ] ) ; } | Returns the 2D point on geometry A that is closest to geometry B . |
6,095 | public static MultiLineString createSegments ( Geometry geom ) throws SQLException { if ( geom != null ) { List < LineString > result ; if ( geom . getDimension ( ) > 0 ) { result = new LinkedList < LineString > ( ) ; createSegments ( geom , result ) ; return GEOMETRY_FACTORY . createMultiLineString ( result . toArray ... | Converts a geometry into a set of distinct segments stored in a MultiLineString . |
6,096 | public static void writeGeoJson ( Connection connection , String fileName , String tableReference , String encoding ) throws IOException , SQLException { GeoJsonDriverFunction geoJsonDriver = new GeoJsonDriverFunction ( ) ; geoJsonDriver . exportTable ( connection , tableReference , URIUtilities . fileFromString ( file... | Write the GeoJSON file . |
6,097 | public static Geometry removeHoles ( Geometry geometry ) { if ( geometry == null ) { return null ; } if ( geometry instanceof Polygon ) { return removeHolesPolygon ( ( Polygon ) geometry ) ; } else if ( geometry instanceof MultiPolygon ) { return removeHolesMultiPolygon ( ( MultiPolygon ) geometry ) ; } else if ( geome... | Remove any holes from the geometry . If the geometry doesn t contain any holes return it unchanged . |
6,098 | public static MultiPolygon removeHolesMultiPolygon ( MultiPolygon multiPolygon ) { int num = multiPolygon . getNumGeometries ( ) ; Polygon [ ] polygons = new Polygon [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { polygons [ i ] = removeHolesPolygon ( ( Polygon ) multiPolygon . getGeometryN ( i ) ) ; } return multiPolyg... | Create a new multiPolygon without hole . |
6,099 | public static Polygon removeHolesPolygon ( Polygon polygon ) { return new Polygon ( ( LinearRing ) polygon . getExteriorRing ( ) , null , polygon . getFactory ( ) ) ; } | Create a new polygon without hole . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.