idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
129,700 | 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 |
129,701 | 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 . |
129,702 | 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 . |
129,703 | 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 |
129,704 | 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 |
129,705 | 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 . |
129,706 | public static MultiPoint removeCoordinates ( MultiPoint g ) { Coordinate [ ] coords = CoordinateUtils . removeDuplicatedCoordinates ( g . getCoordinates ( ) , false ) ; return FACTORY . createMultiPoint ( coords ) ; } | Removes duplicated coordinates within a MultiPoint . |
129,707 | 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 |
129,708 | 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 . |
129,709 | public static Geometry computeBoundingCircle ( Geometry geometry ) { if ( geometry == null ) { return null ; } return new MinimumBoundingCircle ( geometry ) . getCircle ( ) ; } | Computes the bounding circle |
129,710 | 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 . |
129,711 | 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 . |
129,712 | 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 . |
129,713 | 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 |
129,714 | 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 . |
129,715 | 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 . |
129,716 | 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 . |
129,717 | 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 . |
129,718 | 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 . |
129,719 | 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 . |
129,720 | 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 |
129,721 | public static TableLocation suffixTableLocation ( TableLocation inputTable , String suffix ) { return new TableLocation ( inputTable . getCatalog ( ) , inputTable . getSchema ( ) , inputTable . getTable ( ) + suffix ) ; } | Suffix a TableLocation |
129,722 | 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 |
129,723 | public static CoordinateSequenceDimensionFilter apply ( Geometry geometry ) { CoordinateSequenceDimensionFilter cd = new CoordinateSequenceDimensionFilter ( ) ; geometry . apply ( cd ) ; return cd ; } | Init CoordinateSequenceDimensionFilter object . |
129,724 | 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 . |
129,725 | 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 |
129,726 | 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 . |
129,727 | 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 . |
129,728 | 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 |
129,729 | 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 |
129,730 | 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 |
129,731 | 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 . |
129,732 | 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 . |
129,733 | 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 |
129,734 | 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 |
129,735 | 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 |
129,736 | 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 . |
129,737 | 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 |
129,738 | 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 ] . |
129,739 | 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 . |
129,740 | 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 . |
129,741 | 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 |
129,742 | 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 . |
129,743 | 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 . |
129,744 | 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 . |
129,745 | 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 |
129,746 | 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 . |
129,747 | 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 |
129,748 | 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 . |
129,749 | 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 . |
129,750 | 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 . |
129,751 | 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 . |
129,752 | 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 . |
129,753 | 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 |
129,754 | 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 |
129,755 | 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 |
129,756 | 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 |
129,757 | public void addSegment ( Coordinate p0 , Coordinate p1 ) { if ( p0 . distance ( p1 ) < epsilon ) { return ; } addSegment ( originalSegments , p0 , p1 ) ; } | Add occlusion segment in isovist |
129,758 | 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 |
129,759 | 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 |
129,760 | 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 |
129,761 | 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 . |
129,762 | 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 . |
129,763 | 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 . |
129,764 | 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 . |
129,765 | 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 . |
129,766 | 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 |
129,767 | 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 |
129,768 | 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 |
129,769 | 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 |
129,770 | 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 . |
129,771 | 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 . |
129,772 | 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 . |
129,773 | 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 . |
129,774 | 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 |
129,775 | 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 |
129,776 | 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 . |
129,777 | 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 . |
129,778 | 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 . |
129,779 | 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 . |
129,780 | 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 |
129,781 | 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 |
129,782 | 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 |
129,783 | 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 |
129,784 | 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 . |
129,785 | 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 . |
129,786 | 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 . |
129,787 | 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 . |
129,788 | 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 . |
129,789 | public static Polygon removeHolesPolygon ( Polygon polygon ) { return new Polygon ( ( LinearRing ) polygon . getExteriorRing ( ) , null , polygon . getFactory ( ) ) ; } | Create a new polygon without hole . |
129,790 | private static LineString linearZInterpolation ( LineString lineString ) { double startz = lineString . getStartPoint ( ) . getCoordinate ( ) . z ; double endz = lineString . getEndPoint ( ) . getCoordinate ( ) . z ; if ( Double . isNaN ( startz ) || Double . isNaN ( endz ) ) { return lineString ; } else { double lengt... | Interpolate a linestring according the start and the end coordinates z value . If the start or the end z is NaN return the input linestring |
129,791 | private static MultiLineString linearZInterpolation ( MultiLineString multiLineString ) { int nbGeom = multiLineString . getNumGeometries ( ) ; LineString [ ] lines = new LineString [ nbGeom ] ; for ( int i = 0 ; i < nbGeom ; i ++ ) { LineString subGeom = ( LineString ) multiLineString . getGeometryN ( i ) ; double sta... | Interpolate each linestring of the multilinestring . |
129,792 | public boolean isMultiPoint ( ) { boolean mp = true ; if ( this == UNDEFINED ) { mp = false ; } else if ( this == NULL ) { mp = false ; } else if ( this == POINT ) { mp = false ; } return mp ; } | Is this a multipoint shape? Hint - all shapes are multipoint except NULL UNDEFINED and the POINTs . |
129,793 | public static ShapeType forID ( int id ) { ShapeType t ; switch ( id ) { case 0 : t = NULL ; break ; case 1 : t = POINT ; break ; case 11 : t = POINTZ ; break ; case 21 : t = POINTM ; break ; case 3 : t = ARC ; break ; case 13 : t = ARCZ ; break ; case 23 : t = ARCM ; break ; case 5 : t = POLYGON ; break ; case 15 : t ... | Determine the ShapeType for the id . |
129,794 | public ShapeHandler getShapeHandler ( ) throws ShapefileException { ShapeHandler handler ; switch ( id ) { case 1 : case 11 : case 21 : handler = new PointHandler ( this ) ; break ; case 3 : case 13 : case 23 : handler = new MultiLineHandler ( this ) ; break ; case 5 : case 15 : case 25 : handler = new PolygonHandler (... | Each ShapeType corresponds to a handler . In the future this should probably go else where to allow different handlers or something ... |
129,795 | public static PreparedStatement createTagTable ( Connection connection , String tagTableName ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { stmt . execute ( "CREATE TABLE " + tagTableName + "(ID_TAG SERIAL PRIMARY KEY, TAG_KEY VARCHAR UNIQUE);" ) ; } return connection . prepareState... | Create the tag table to store all key and value |
129,796 | public static PreparedStatement createWayTagTable ( Connection connection , String wayTagTableName , String tagTableName ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { StringBuilder sb = new StringBuilder ( "CREATE TABLE " ) ; sb . append ( wayTagTableName ) ; sb . append ( "(ID_WAY... | Create a table to store the way tags . |
129,797 | public static PreparedStatement createWayNodeTable ( Connection connection , String wayNodeTableName ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { StringBuilder sb = new StringBuilder ( "CREATE TABLE " ) ; sb . append ( wayNodeTableName ) ; sb . append ( "(ID_WAY BIGINT, ID_NODE BI... | Create a table to store the list of nodes for each way . |
129,798 | public static PreparedStatement createRelationTable ( Connection connection , String relationTable ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { StringBuilder sb = new StringBuilder ( "CREATE TABLE " ) ; sb . append ( relationTable ) ; sb . append ( "(ID_RELATION BIGINT PRIMARY KEY... | Create the relation table . |
129,799 | public static PreparedStatement createNodeMemberTable ( Connection connection , String nodeMemberTable ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { StringBuilder sb = new StringBuilder ( "CREATE TABLE " ) ; sb . append ( nodeMemberTable ) ; sb . append ( "(ID_RELATION BIGINT,ID_NO... | Create the node members table |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.