idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
129,600 | protected String parseEdgeOrientation ( String v ) { if ( v == null ) { return null ; } if ( ! v . contains ( SEPARATOR ) ) { throw new IllegalArgumentException ( ORIENTATION_ERROR ) ; } String [ ] s = v . split ( SEPARATOR ) ; if ( s . length == 2 ) { return s [ 1 ] . trim ( ) ; } else { throw new IllegalArgumentExcep... | Recovers the edge orientation from a string . |
129,601 | 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 string... | Returns an array of destination ids from a comma - separated list of destinations . |
129,602 | public void initialise ( XMLReader reader , AbstractGpxParserDefault parent ) { setReader ( reader ) ; setParent ( parent ) ; setContentBuffer ( parent . getContentBuffer ( ) ) ; setTrkPreparedStmt ( parent . getTrkPreparedStmt ( ) ) ; setTrkSegmentsPreparedStmt ( parent . getTrkSegmentsPreparedStmt ( ) ) ; setTrkPoint... | Create a new specific parser . It has in memory the default parser the contentBuffer the elementNames the currentLine and the trkID . |
129,603 | 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 . ALLO... | Convert a geojson geometry to geometry . |
129,604 | public static Double perimeter ( Geometry geometry ) { if ( geometry == null ) { return null ; } if ( geometry . getDimension ( ) < 2 ) { return 0d ; } return computePerimeter ( geometry ) ; } | Compute the perimeter of a polygon or a multipolygon . |
129,605 | 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 ; ... | Compute the perimeter |
129,606 | 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 . |
129,607 | public static Geometry simplyPreserve ( Geometry geometry , double distance ) { if ( geometry == null ) { return null ; } return TopologyPreservingSimplifier . simplify ( geometry , distance ) ; } | 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 . |
129,608 | 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 Grap... | Return a JGraphT graph from the input edges table . |
129,609 | 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 Coor... | Compute the polygon corresponding to the cell |
129,610 | 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 ) ) ; } | Compute the point of the cell |
129,611 | private static String getFirstGeometryField ( String tableName , Connection connection ) throws SQLException { List < String > geomFields = SFSUtilities . getGeometryFields ( connection , TableLocation . parse ( tableName , JDBCUtilities . isH2DataBase ( connection . getMetaData ( ) ) ) ) ; if ( ! geomFields . isEmpty ... | Return the first spatial geometry field name |
129,612 | 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 )... | Compute the parameters need to create each cells |
129,613 | 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_R... | Give the regular grid |
129,614 | 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 = ( ( Po... | This code compute the angle in radian as postgis does . |
129,615 | 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 . |
129,616 | private Point parsePoint ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; String coordinatesField = jp . getText ( ) ; if ( coordinatesField . equalsIgnoreCase ( GeoJsonField . COORDINATES ) ) { jp . nextToken ( ) ; Point point = GF . createPoint ( parseCoordinate ( jp ) ) ; jp . nextToken ( )... | Parses one position |
129,617 | private MultiPoint parseMultiPoint ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; String coordinatesField = jp . getText ( ) ; if ( coordinatesField . equalsIgnoreCase ( GeoJsonField . COORDINATES ) ) { jp . nextToken ( ) ; MultiPoint mPoint = GF . createMultiPoint ( parseCoordinates ( jp ) ... | Parses an array of positions |
129,618 | private Coordinate parseCoordinate ( JsonParser jp ) throws IOException { jp . nextToken ( ) ; double x = jp . getDoubleValue ( ) ; jp . nextToken ( ) ; double y = jp . getDoubleValue ( ) ; Coordinate coord ; jp . nextToken ( ) ; if ( jp . getCurrentToken ( ) == JsonToken . END_ARRAY ) { coord = new Coordinate ( x , y ... | 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 ] . |
129,619 | 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 ( ... | Constructs a MultiLineString from the given geometry s coordinates . |
129,620 | 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 ( ... | Copy data from TSV File into a new table in specified connection . |
129,621 | 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 ) . tr... | Translates a geometry using X and Y offsets . |
129,622 | 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 ) ; if ( filter . is2D ( ) ) { return AffineTransformatio... | Translates a geometry using X Y and Z offsets . |
129,623 | 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 SQLExcep... | Convert a WKB representation to a geometry |
129,624 | public static Double maxDistance ( Geometry geomA , Geometry geomB ) { return new MaxDistanceOp ( geomA , geomB ) . getDistance ( ) ; } | Return the maximum distance |
129,625 | public void characters ( char [ ] ch , int start , int length ) throws SAXException { contentBuffer . append ( String . copyValueOf ( ch , start , length ) ) ; } | Fires one or more times for each text node encountered . It saves text informations in contentBuffer . |
129,626 | 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 . contai... | Quote identifier only if necessary . Require database knowledge . |
129,627 | 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 openQ... | Convert catalog . schema . table schema . table or table into a TableLocation instance . Non - specified schema or catalogs are converted to the empty string . |
129,628 | public static String capsIdentifier ( String identifier , Boolean isH2Database ) { if ( isH2Database != null ) { if ( isH2Database ) { return identifier . toUpperCase ( ) ; } else { return identifier . toLowerCase ( ) ; } } else { return identifier ; } } | Change case of parameters to make it more user - friendly . |
129,629 | 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 ) ;... | Decompose a geometry recursively into simple components . |
129,630 | 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 . ge... | Reursively remove geometries with a dimension less than dimension parameter |
129,631 | 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 ... | Union adjacent polygons to make an invalid MultiPolygon valid |
129,632 | 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 . isN... | If X or Y is null return an empty Point |
129,633 | private static CoordinateSequence makeSequenceValid ( CoordinateSequence sequence , boolean preserveDuplicateCoord , boolean close ) { int dim = sequence . getDimension ( ) ; double [ ] array = new double [ ( sequence . size ( ) + 1 ) * sequence . getDimension ( ) ] ; boolean modified = false ; int count = 0 ; for ( in... | 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 . |
129,634 | 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 = li... | Return a set of segments from a linestring |
129,635 | 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 ( Geomet... | Use ring to restore M values on geoms |
129,636 | 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 ... | Use map to restore M values on the coordinate array |
129,637 | 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 ) { ... | Creat the track table |
129,638 | 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... | Create the track segments table to store the segments of a track |
129,639 | 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 ,... | Drop the existing GPX tables used to store the imported OSM GPX |
129,640 | 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_A... | Generate a string value corresponding to the altitude mode . |
129,641 | public static GeometryCollection extrudePolygonAsGeometry ( Polygon polygon , double height ) { GeometryFactory factory = polygon . getFactory ( ) ; Geometry [ ] geometries = new Geometry [ 3 ] ; final LineString shell = getClockWise ( polygon . getExteriorRing ( ) ) ; ArrayList < Polygon > walls = new ArrayList < Poly... | Extrude the polygon as a collection of geometries The output geometryCollection contains the floor the walls and the roof . |
129,642 | public static GeometryCollection extrudeLineStringAsGeometry ( LineString lineString , double height ) { Geometry [ ] geometries = new Geometry [ 3 ] ; GeometryFactory factory = lineString . getFactory ( ) ; Coordinate [ ] coords = lineString . getCoordinates ( ) ; Polygon [ ] walls = new Polygon [ coords . length - 1 ... | Extrude the linestring as a collection of geometries The output geometryCollection contains the floor the walls and the roof . |
129,643 | public static Geometry extractRoof ( LineString lineString , double height ) { LineString result = ( LineString ) lineString . copy ( ) ; result . apply ( new TranslateCoordinateSequenceFilter ( height ) ) ; return result ; } | Extract the linestring roof . |
129,644 | public static MultiPolygon extractWalls ( Polygon polygon , double height ) { GeometryFactory factory = polygon . getFactory ( ) ; final LineString shell = getClockWise ( polygon . getExteriorRing ( ) ) ; ArrayList < Polygon > walls = new ArrayList < Polygon > ( ) ; for ( int i = 1 ; i < shell . getNumPoints ( ) ; i ++... | Extract the walls from a polygon |
129,645 | 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 ( r... | Extract the roof of a polygon |
129,646 | public static MultiPolygon extractWalls ( LineString lineString , double height ) { GeometryFactory factory = lineString . getFactory ( ) ; Coordinate [ ] coords = lineString . getCoordinates ( ) ; Polygon [ ] walls = new Polygon [ coords . length - 1 ] ; for ( int i = 0 ; i < coords . length - 1 ; i ++ ) { walls [ i ]... | Extrude the LineString as a set of walls . |
129,647 | 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... | Reverse the LineString to be oriented clockwise . All NaN z values are replaced by a zero value . |
129,648 | 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 )... | Reverse the LineString to be oriented counter - clockwise . |
129,649 | 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 [ ]... | Reverse the polygon to be oriented clockwise |
129,650 | 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 Co... | Create a polygon corresponding to the wall . |
129,651 | public static String fetchConstraint ( Connection connection , String catalogName , String schemaName , String tableName ) throws SQLException { PreparedStatement pst = SFSUtilities . prepareInformationSchemaStatement ( connection , catalogName , schemaName , tableName , "INFORMATION_SCHEMA.CONSTRAINTS" , "" , "TABLE_C... | Read table constraints from database metadata . |
129,652 | 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 Prope... | Convert JDBC URL into JDBC Connection properties |
129,653 | 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 Multi... | Update the start and end Z values . If the interpolate is true the vertices are interpolated according the start and end z values . |
129,654 | 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 ( ) . leng... | Updates all z values by a new value using the specified first and the last coordinates . |
129,655 | public boolean push ( String newText ) { if ( stackTop < stack . length - 1 ) { stack [ stackTop ++ ] = newText ; return true ; } else { return false ; } } | Puts string in the stack . |
129,656 | 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 ne... | Moves the window if necessary to contain the desired byte and returns the position of the byte in the window |
129,657 | private static long getJulianCycle ( double J , double lw ) { return Math . round ( J - J2000 - J0 - lw / ( 2 * Math . PI ) ) ; } | general sun calculations |
129,658 | private static double getApproxTransit ( double Ht , double lw , double n ) { return J2000 + J0 + ( Ht + lw ) / ( 2 * Math . PI ) + n ; } | calculations for sun times |
129,659 | private static double getRightAscension ( double Ls ) { return Math . atan2 ( Math . sin ( Ls ) * Math . cos ( e ) , Math . cos ( Ls ) ) ; } | calculations for sun position |
129,660 | 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 ... | Returns the sun position as a coordinate with the following properties |
129,661 | public int getContentLength ( int index ) throws IOException { int ret = - 1 ; if ( this . lastIndex != index ) { this . readRecord ( index ) ; } ret = this . recLen ; return ret ; } | Get the content length of the given record in bytes not 16 bit words . |
129,662 | public static Geometry reverse ( Geometry geometry ) { if ( geometry == null ) { return null ; } if ( geometry instanceof MultiPoint ) { return reverseMultiPoint ( ( MultiPoint ) geometry ) ; } return geometry . reverse ( ) ; } | Returns the geometry with vertex order reversed . |
129,663 | 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 ... | Returns the MultiPoint with vertex order reversed . We do our own implementation here because JTS does not handle it . |
129,664 | 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 G... | Creates a rectangular Polygon formed from the minima and maxima by the given shell . |
129,665 | 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 ; } | Creates a rectangular Polygon formed from the minima and maxima by the given shell . The user can set a srid . |
129,666 | public static Geometry simplify ( Geometry geometry , double distance ) { if ( geometry == null ) { return null ; } return DouglasPeuckerSimplifier . simplify ( geometry , distance ) ; } | Simplify the geometry using the douglad peucker algorithm . |
129,667 | public static Geometry expand ( Geometry geometry , double deltaX , double deltaY ) { if ( geometry == null ) { return null ; } Envelope env = geometry . getEnvelopeInternal ( ) ; double minX = env . getMinX ( ) - deltaX ; double maxX = env . getMaxX ( ) + deltaX ; double minY = env . getMinY ( ) - deltaY ; double maxY... | Expands a geometry s envelope by the given delta X and delta Y . Both positive and negative distances are supported . |
129,668 | public static LineString computeDirection ( Geometry geometry ) throws IllegalArgumentException { if ( geometry == null ) { return null ; } Triangle triangle = TINFeatureFactory . createTriangle ( geometry ) ; Vector3D normal = TriMarkers . getNormalVector ( triangle ) ; Vector3D vector = new Vector3D ( normal . getX (... | Compute the main slope direction |
129,669 | public static Geometry drapePoints ( Geometry pts , Geometry triangles , STRtree sTRtree ) { Geometry geomDrapped = pts . copy ( ) ; CoordinateSequenceFilter drapeFilter = new DrapeFilter ( sTRtree ) ; geomDrapped . apply ( drapeFilter ) ; return geomDrapped ; } | Drape a point or a multipoint geometry to a set of triangles |
129,670 | public static Geometry drapeLineString ( LineString line , Geometry triangles , STRtree sTRtree ) { GeometryFactory factory = line . getFactory ( ) ; Geometry triangleLines = LinearComponentExtracter . getGeometry ( triangles , true ) ; Geometry diffExt = lineMerge ( line . difference ( triangleLines ) , factory ) ; Co... | Drape a linestring to a set of triangles |
129,671 | public static Geometry drapePolygon ( Polygon p , Geometry triangles , STRtree sTRtree ) { GeometryFactory factory = p . getFactory ( ) ; Geometry triangleLines = LinearComponentExtracter . getGeometry ( triangles , true ) ; Polygon splittedP = processPolygon ( p , triangleLines , factory ) ; CoordinateSequenceFilter d... | Drape a polygon on a set of triangles |
129,672 | 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 < nbOfHo... | Cut the lines of the polygon with the triangles |
129,673 | public static Geometry lineMerge ( Geometry geom , GeometryFactory factory ) { LineMerger merger = new LineMerger ( ) ; merger . add ( geom ) ; Collection lines = merger . getMergedLineStrings ( ) ; return factory . buildGeometry ( lines ) ; } | A method to merge a geometry to a set of linestring |
129,674 | 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 ) ) ; GeometryPrecisio... | Reduce the geometry precision . Decimal_Place is the number of decimals to keep . |
129,675 | 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 |
129,676 | 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 ... | Compute the aspect in degree . The geometry must be a triangle . |
129,677 | public static Double getMinZ ( Geometry geom ) { if ( geom != null ) { return CoordinateUtils . zMinMax ( geom . getCoordinates ( ) ) [ 0 ] ; } else { return null ; } } | Returns the minimal z - value of the given geometry . |
129,678 | 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 . isN... | Reverses a LineString according to the z value . The z of the first point must be lower than the z of the end point . |
129,679 | 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... | 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 . |
129,680 | 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 ; } | An alternative to Stack . toArray which is not present in earlier versions of Java . |
129,681 | 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 ( ) ; while ( ! ps . empty ( ... | Uses the Graham Scan algorithm to compute the convex hull vertices . |
129,682 | 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 . |
129,683 | public static Boolean isWithinDistance ( Geometry geomA , Geometry geomB , Double distance ) { if ( geomA == null || geomB == null ) { return null ; } return geomA . isWithinDistance ( geomB , distance ) ; } | Returns true if the geometries are within the specified distance of one another . |
129,684 | public static String toGeojson ( Geometry geom ) { StringBuilder sb = new StringBuilder ( ) ; toGeojsonGeometry ( geom , sb ) ; return sb . toString ( ) ; } | Convert the geometry to a GeoJSON representation . |
129,685 | 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 , ... | Transform a JTS geometry to a GeoJSON representation . |
129,686 | 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... | For type Point the coordinates member must be a single position . |
129,687 | public static void toGeojsonMultiPoint ( MultiPoint multiPoint , StringBuilder sb ) { sb . append ( "{\"type\":\"MultiPoint\",\"coordinates\":" ) ; toGeojsonCoordinates ( multiPoint . getCoordinates ( ) , sb ) ; sb . append ( "}" ) ; } | Coordinates of a MultiPoint are an array of positions . |
129,688 | public static void toGeojsonLineString ( LineString lineString , StringBuilder sb ) { sb . append ( "{\"type\":\"LineString\",\"coordinates\":" ) ; toGeojsonCoordinates ( lineString . getCoordinates ( ) , sb ) ; sb . append ( "}" ) ; } | Coordinates of LineString are an array of positions . |
129,689 | 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 ( ... | Coordinates of a MultiLineString are an array of LineString coordinate arrays . |
129,690 | 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 . |
129,691 | 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 . |
129,692 | 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 . |
129,693 | 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 . |
129,694 | 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 . |
129,695 | 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 |
129,696 | 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 |
129,697 | 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 |
129,698 | 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 . |
129,699 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.