idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
129,900
public static void unRegisterFunction ( Statement st , Function function ) throws SQLException { String functionAlias = getStringProperty ( function , Function . PROP_NAME ) ; if ( functionAlias . isEmpty ( ) ) { functionAlias = function . getClass ( ) . getSimpleName ( ) ; } st . execute ( "DROP ALIAS IF EXISTS " + fu...
Remove the specified function from the provided DataBase connection
129,901
private static void registerH2GISFunctions ( Connection connection , String packagePrepend ) throws SQLException { Statement st = connection . createStatement ( ) ; for ( Function function : getBuiltInsFunctions ( ) ) { try { registerFunction ( st , function , packagePrepend ) ; } catch ( SQLException ex ) { ex . print...
Register all H2GIS functions
129,902
public static void unRegisterH2GISFunctions ( Connection connection ) throws SQLException { Statement st = connection . createStatement ( ) ; for ( Function function : getBuiltInsFunctions ( ) ) { unRegisterFunction ( st , function ) ; } unRegisterGeometryType ( connection ) ; }
Unregister spatial type and H2GIS functions from the current connection .
129,903
public static String isValidReason ( Geometry geometry , int flag ) { if ( geometry != null ) { if ( flag == 0 ) { return validReason ( geometry , false ) ; } else if ( flag == 1 ) { return validReason ( geometry , true ) ; } else { throw new IllegalArgumentException ( "Supported arguments are 0 or 1." ) ; } } return "...
Returns text stating whether a geometry is valid . If not returns a reason why .
129,904
public static Geometry polygonize ( Geometry geometry ) { if ( geometry == null ) { return null ; } Polygonizer polygonizer = new Polygonizer ( ) ; polygonizer . add ( geometry ) ; Collection pols = polygonizer . getPolygons ( ) ; if ( pols . isEmpty ( ) ) { return null ; } return FACTORY . createMultiPolygon ( Geometr...
Creates a GeometryCollection containing possible polygons formed from the constituent linework of a set of geometries .
129,905
private void computeMaxDistance ( ) { HashSet < Coordinate > coordinatesA = new HashSet < Coordinate > ( Arrays . asList ( geomA . convexHull ( ) . getCoordinates ( ) ) ) ; Geometry fullHull = geomA . getFactory ( ) . createGeometryCollection ( new Geometry [ ] { geomA , geomB } ) . convexHull ( ) ; maxDistanceFilter =...
Compute the max distance
129,906
public Double getDistance ( ) { if ( geomA == null || geomB == null ) { return null ; } if ( geomA . isEmpty ( ) || geomB . isEmpty ( ) ) { return 0.0 ; } if ( geomA . equals ( geomB ) ) { sameGeom = true ; } if ( maxDistanceFilter == null ) { computeMaxDistance ( ) ; } return maxDistanceFilter . getDistance ( ) ; }
Return the max distance
129,907
public Coordinate [ ] getCoordinatesDistance ( ) { if ( geomA == null || geomB == null ) { return null ; } if ( geomA . isEmpty ( ) || geomB . isEmpty ( ) ) { return null ; } if ( geomA . equals ( geomB ) ) { sameGeom = true ; } if ( maxDistanceFilter == null ) { computeMaxDistance ( ) ; } return maxDistanceFilter . ge...
Return the two coordinates to build the max distance line
129,908
public static Geometry toGeometry ( String gmlFile , int srid ) throws SAXException , IOException , ParserConfigurationException { if ( gmlFile == null ) { return null ; } if ( gf == null ) { gf = new GeometryFactory ( new PrecisionModel ( ) , srid ) ; } GMLReader gMLReader = new GMLReader ( ) ; return gMLReader . read...
Read the GML representation with a specified SRID
129,909
public void write ( ProgressVisitor progress , ResultSet rs , File fileName , String encoding ) throws SQLException , IOException { if ( FileUtil . isExtensionWellFormated ( fileName , "geojson" ) ) { FileOutputStream fos = null ; JsonEncoding jsonEncoding = JsonEncoding . UTF8 ; if ( encoding != null ) { try { jsonEnc...
Write a resulset to a geojson file
129,910
private void writeFeature ( JsonGenerator jsonGenerator , ResultSet rs , int geoFieldIndex ) throws IOException , SQLException { jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeStringField ( "type" , "Feature" ) ; writeGeometry ( ( Geometry ) rs . getObject ( geoFieldIndex ) , jsonGenerator ) ; writePropert...
Write a GeoJSON feature .
129,911
private void cacheMetadata ( ResultSetMetaData resultSetMetaData ) throws SQLException { cachedColumnNames = new LinkedHashMap < String , Integer > ( ) ; for ( int i = 1 ; i <= resultSetMetaData . getColumnCount ( ) ; i ++ ) { final String fieldTypeName = resultSetMetaData . getColumnTypeName ( i ) ; if ( ! fieldTypeNa...
Cache the column name and its index .
129,912
private void writeGeometry ( Geometry geom , JsonGenerator gen ) throws IOException { if ( geom != null ) { gen . writeObjectFieldStart ( "geometry" ) ; if ( geom instanceof Point ) { write ( ( Point ) geom , gen ) ; } else if ( geom instanceof MultiPoint ) { write ( ( MultiPoint ) geom , gen ) ; } else if ( geom insta...
Write a JTS geometry to its GeoJSON geometry representation .
129,913
private void writeProperties ( JsonGenerator jsonGenerator , ResultSet rs ) throws IOException , SQLException { if ( columnCountProperties != - 1 ) { jsonGenerator . writeObjectFieldStart ( "properties" ) ; for ( Map . Entry < String , Integer > entry : cachedColumnNames . entrySet ( ) ) { String string = entry . getKe...
Write the GeoJSON properties .
129,914
public boolean isSupportedPropertyType ( int sqlTypeId , String sqlTypeName ) throws SQLException { switch ( sqlTypeId ) { case Types . BOOLEAN : case Types . DOUBLE : case Types . FLOAT : case Types . INTEGER : case Types . BIGINT : case Types . SMALLINT : case Types . DATE : case Types . VARCHAR : case Types . NCHAR ...
Return true is the SQL type is supported by the GeoJSON driver .
129,915
private void writeCRS ( JsonGenerator jsonGenerator , String [ ] authorityAndSRID ) throws IOException { if ( authorityAndSRID [ 1 ] != null ) { jsonGenerator . writeObjectFieldStart ( "crs" ) ; jsonGenerator . writeStringField ( "type" , "name" ) ; jsonGenerator . writeObjectFieldStart ( "properties" ) ; StringBuilder...
Write the CRS in the geojson
129,916
private void writeArray ( JsonGenerator jsonGenerator , Object [ ] array , boolean firstInHierarchy ) throws IOException , SQLException { if ( ! firstInHierarchy ) { jsonGenerator . writeStartArray ( ) ; } for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] instanceof Integer ) { jsonGenerator . writeNumbe...
Write the array in the geojson
129,917
public static Geometry singleSideBuffer ( Geometry geometry , double distance ) { if ( geometry == null ) { return null ; } return computeSingleSideBuffer ( geometry , distance , new BufferParameters ( ) ) ; }
Compute a single side buffer with default parameters
129,918
private static Geometry computeSingleSideBuffer ( Geometry geometry , double distance , BufferParameters bufferParameters ) { bufferParameters . setSingleSided ( true ) ; return BufferOp . bufferOp ( geometry , distance , bufferParameters ) ; }
Compute the buffer
129,919
public static Boolean geomEquals ( Geometry a , Geometry b ) { if ( a == null || b == null ) { return null ; } return a . equals ( b ) ; }
Return true if Geometry A is equal to Geometry B
129,920
private void addGeometry ( Geometry geom ) { if ( geom != null ) { if ( geom instanceof GeometryCollection ) { List < Geometry > toUnitTmp = new ArrayList < Geometry > ( geom . getNumGeometries ( ) ) ; for ( int i = 0 ; i < geom . getNumGeometries ( ) ; i ++ ) { toUnitTmp . add ( geom . getGeometryN ( i ) ) ; feedDim (...
Add geometry into an array to accumulate
129,921
public void exportTable ( Connection connection , String tableReference , File fileName , ProgressVisitor progress , String encoding ) throws SQLException , IOException { GeoJsonWriteDriver geoJsonDriver = new GeoJsonWriteDriver ( connection ) ; geoJsonDriver . write ( progress , tableReference , fileName , encoding ) ...
Export a table or a query to a geojson file
129,922
public void startElement ( String uri , String localName , String qName , Attributes attributes ) throws SAXException { if ( localName . compareToIgnoreCase ( "osm" ) == 0 ) { version = attributes . getValue ( GPXTags . VERSION ) ; } else if ( localName . compareToIgnoreCase ( "node" ) == 0 ) { totalNode ++ ; } else if...
Fires whenever an XML start markup is encountered . It indicates which version of osm file is to be parsed .
129,923
public static Geometry addPoint ( Geometry geometry , Point point ) throws SQLException { return addPoint ( geometry , point , PRECISION ) ; }
Returns a new geometry based on an existing one with a specific point as a new vertex . A default distance 10E - 6 is used to snap the input point .
129,924
public static Geometry addPoint ( Geometry geometry , Point point , double tolerance ) throws SQLException { if ( geometry == null || point == null ) { return null ; } if ( geometry instanceof MultiPoint ) { return insertVertexInMultipoint ( geometry , point ) ; } else if ( geometry instanceof LineString ) { return ins...
Returns a new geometry based on an existing one with a specific point as a new vertex .
129,925
private static Geometry insertVertexInMultipoint ( Geometry g , Point vertexPoint ) { ArrayList < Point > geoms = new ArrayList < Point > ( ) ; for ( int i = 0 ; i < g . getNumGeometries ( ) ; i ++ ) { Point geom = ( Point ) g . getGeometryN ( i ) ; geoms . add ( geom ) ; } geoms . add ( FACTORY . createPoint ( new Coo...
Adds a Point into a MultiPoint geometry .
129,926
private static Polygon insertVertexInPolygon ( Polygon polygon , Point vertexPoint , double tolerance ) throws SQLException { Polygon geom = polygon ; LineString linearRing = polygon . getExteriorRing ( ) ; int index = - 1 ; for ( int i = 0 ; i < polygon . getNumInteriorRing ( ) ; i ++ ) { double distCurr = computeDist...
Adds a vertex into a Polygon with a given tolerance .
129,927
private static double computeDistance ( Geometry geometry , Point vertexPoint , double tolerance ) { DistanceOp distanceOp = new DistanceOp ( geometry , vertexPoint , tolerance ) ; return distanceOp . distance ( ) ; }
Return minimum distance between a geometry and a point .
129,928
private static LinearRing insertVertexInLinearRing ( LineString lineString , Point vertexPoint , double tolerance ) { GeometryLocation geomLocation = EditUtilities . getVertexToSnap ( lineString , vertexPoint , tolerance ) ; if ( geomLocation != null ) { Coordinate [ ] coords = lineString . getCoordinates ( ) ; int ind...
Adds a vertex into a LinearRing with a given tolerance .
129,929
public static void openFile ( Connection connection , String fileName , String tableName ) throws SQLException { String ext = fileName . substring ( fileName . lastIndexOf ( '.' ) + 1 , fileName . length ( ) ) ; final boolean isH2 = JDBCUtilities . isH2DataBase ( connection . getMetaData ( ) ) ; for ( DriverDef driverD...
Create a new table
129,930
public static void exportTable ( Connection connection , String fileName , String tableReference , String encoding ) throws IOException , SQLException { SHPDriverFunction shpDriverFunction = new SHPDriverFunction ( ) ; shpDriverFunction . exportTable ( connection , tableReference , URIUtilities . fileFromString ( fileN...
Read a table and write it into a shape file .
129,931
public static Geometry force ( Geometry geom , int dimension ) { if ( geom instanceof Point ) { return gf . createPoint ( convertSequence ( geom . getCoordinates ( ) , dimension ) ) ; } else if ( geom instanceof LineString ) { return gf . createLineString ( convertSequence ( geom . getCoordinates ( ) , dimension ) ) ; ...
Force the dimension of the geometry and update correctly the coordinate dimension
129,932
public static GeometryCollection convert ( GeometryCollection gc , int dimension ) { int nb = gc . getNumGeometries ( ) ; final Geometry [ ] geometries = new Geometry [ nb ] ; for ( int i = 0 ; i < nb ; i ++ ) { geometries [ i ] = force ( gc . getGeometryN ( i ) , dimension ) ; } return gf . createGeometryCollection ( ...
Force the dimension of the GeometryCollection and update correctly the coordinate dimension
129,933
public static MultiPolygon convert ( MultiPolygon multiPolygon , int dimension ) { int nb = multiPolygon . getNumGeometries ( ) ; final Polygon [ ] pl = new Polygon [ nb ] ; for ( int i = 0 ; i < nb ; i ++ ) { pl [ i ] = GeometryCoordinateDimension . convert ( ( Polygon ) multiPolygon . getGeometryN ( i ) , dimension )...
Force the dimension of the MultiPolygon and update correctly the coordinate dimension
129,934
public static MultiLineString convert ( MultiLineString multiLineString , int dimension ) { int nb = multiLineString . getNumGeometries ( ) ; final LineString [ ] ls = new LineString [ nb ] ; for ( int i = 0 ; i < nb ; i ++ ) { ls [ i ] = GeometryCoordinateDimension . convert ( ( LineString ) multiLineString . getGeome...
Force the dimension of the MultiLineString and update correctly the coordinate dimension
129,935
public static Polygon convert ( Polygon polygon , int dimension ) { LinearRing shell = GeometryCoordinateDimension . convert ( polygon . getExteriorRing ( ) , dimension ) ; int nbOfHoles = polygon . getNumInteriorRing ( ) ; final LinearRing [ ] holes = new LinearRing [ nbOfHoles ] ; for ( int i = 0 ; i < nbOfHoles ; i ...
Force the dimension of the Polygon and update correctly the coordinate dimension
129,936
public static LinearRing convert ( LineString lineString , int dimension ) { return gf . createLinearRing ( convertSequence ( lineString . getCoordinates ( ) , dimension ) ) ; }
Force the dimension of the LineString and update correctly the coordinate dimension
129,937
public static LinearRing convert ( LinearRing linearRing , int dimension ) { return gf . createLinearRing ( convertSequence ( linearRing . getCoordinates ( ) , dimension ) ) ; }
Force the dimension of the LinearRing and update correctly the coordinate dimension
129,938
private static CoordinateArraySequence convertSequence ( Coordinate [ ] cs , int dimension ) { for ( int i = 0 ; i < cs . length ; i ++ ) { Coordinate coord = cs [ i ] ; switch ( dimension ) { case 2 : coord . z = Double . NaN ; cs [ i ] = coord ; break ; case 3 : { double z = coord . z ; if ( Double . isNaN ( z ) ) { ...
Create a new CoordinateArraySequence and update its dimension
129,939
public static Double computeCompacity ( Geometry geom ) { if ( geom == null ) { return null ; } if ( geom instanceof Polygon ) { final double circleRadius = Math . sqrt ( geom . getArea ( ) / Math . PI ) ; final double circleCurcumference = 2 * Math . PI * circleRadius ; return circleCurcumference / geom . getLength ( ...
Returns the compactness ratio of the given polygon
129,940
public static Double st3darea ( Geometry geometry ) { if ( geometry == null ) { return null ; } double area = 0 ; for ( int idPoly = 0 ; idPoly < geometry . getNumGeometries ( ) ; idPoly ++ ) { Geometry subGeom = geometry . getGeometryN ( idPoly ) ; if ( subGeom instanceof Polygon ) { area += compute3DArea ( ( Polygon ...
Compute the 3D area of a polygon a geometrycollection that contains polygons
129,941
private static Double compute3DArea ( Polygon geometry ) { DelaunayData delaunayData = new DelaunayData ( ) ; delaunayData . put ( geometry , DelaunayData . MODE . TESSELLATION ) ; delaunayData . triangulate ( ) ; return delaunayData . get3DArea ( ) ; }
Compute the 3D area of a polygon
129,942
public static Geometry setSRID ( Geometry geometry , Integer srid ) throws IllegalArgumentException { if ( geometry == null ) { return null ; } if ( srid == null ) { throw new IllegalArgumentException ( "The SRID code cannot be null." ) ; } Geometry geom = geometry . copy ( ) ; geom . setSRID ( srid ) ; return geom ; }
Set a new SRID to the geometry
129,943
public static void writeGeoJson ( Connection connection , String fileName , String tableReference , String encoding ) throws IOException , SQLException { JsonDriverFunction jsonDriver = new JsonDriverFunction ( ) ; jsonDriver . exportTable ( connection , tableReference , URIUtilities . fileFromString ( fileName ) , new...
Write the JSON file .
129,944
public static int geometryTypeFromConstraint ( String constraint , int numericPrecision ) { if ( constraint . isEmpty ( ) && numericPrecision > GeometryTypeCodes . GEOMETRYZM ) { return GeometryTypeCodes . GEOMETRY ; } if ( numericPrecision <= GeometryTypeCodes . GEOMETRYZM ) { return numericPrecision ; } Matcher match...
Convert H2 constraint string into a OGC geometry type index .
129,945
public static String getQuestionMark ( int count ) { StringBuilder qMark = new StringBuilder ( ) ; for ( int i = 0 ; i < count ; i ++ ) { if ( i > 0 ) { qMark . append ( ", " ) ; } qMark . append ( "?" ) ; } return qMark . toString ( ) ; }
Generate the concatenation of ? characters . Used by PreparedStatement .
129,946
public static String getSQLColumnTypes ( DbaseFileHeader header , boolean isH2Database ) throws IOException { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( int idColumn = 0 ; idColumn < header . getNumFields ( ) ; idColumn ++ ) { if ( idColumn > 0 ) { stringBuilder . append ( ", " ) ; } String fieldName =...
Return SQL Columns declaration
129,947
public static DbaseFileHeader dBaseHeaderFromMetaData ( ResultSetMetaData metaData , List < Integer > retainedColumns ) throws SQLException { DbaseFileHeader dbaseFileHeader = new DbaseFileHeader ( ) ; for ( int fieldId = 1 ; fieldId <= metaData . getColumnCount ( ) ; fieldId ++ ) { final String fieldTypeName = metaDat...
Create a DBF header from the columns specified in parameter .
129,948
public static Geometry removePoint ( Geometry geometry , Polygon polygon ) throws SQLException { if ( geometry == null ) { return null ; } GeometryEditor localGeometryEditor = new GeometryEditor ( ) ; PolygonDeleteVertexOperation localBoxDeleteVertexOperation = new PolygonDeleteVertexOperation ( geometry . getFactory (...
Remove all vertices that are located within a polygon
129,949
public static Map < String , String > getQueryKeyValuePairs ( URI uri ) throws UnsupportedEncodingException { Map < String , String > queryParameters = new HashMap < String , String > ( ) ; String query = uri . getRawQuery ( ) ; if ( query == null ) { try { uri = URI . create ( uri . getRawSchemeSpecificPart ( ) ) ; qu...
Read the Query part of an URI .
129,950
public static String getConcatenatedParameters ( Map < String , String > parameters , String ... keys ) { StringBuilder keyValues = new StringBuilder ( ) ; for ( String key : keys ) { String value = parameters . get ( key . toLowerCase ( ) . trim ( ) ) ; if ( value != null ) { if ( keyValues . length ( ) != 0 ) { keyVa...
Create the Query part of an URI
129,951
public static URI relativize ( URI base , URI target ) { if ( ! base . getScheme ( ) . equals ( target . getScheme ( ) ) ) { return target ; } StringBuilder rel = new StringBuilder ( ) ; String path = base . getPath ( ) ; String separator = "/" ; StringTokenizer tokenizer = new StringTokenizer ( target . getPath ( ) , ...
Enhanced version of URI . relativize the target can now be in parent folder of base URI .
129,952
public static File fileFromString ( String fileName ) { try { return new File ( new URI ( fileName ) . getPath ( ) ) ; } catch ( URISyntaxException ex ) { return new File ( fileName ) ; } }
Get a File from the specified file name .
129,953
private static Geometry shadowLine ( LineString lineString , double [ ] shadowOffset , GeometryFactory factory , boolean doUnion ) { Coordinate [ ] coords = lineString . getCoordinates ( ) ; Collection < Polygon > shadows = new ArrayList < Polygon > ( ) ; createShadowPolygons ( shadows , coords , shadowOffset , factory...
Compute the shadow for a linestring
129,954
private static Geometry shadowPolygon ( Polygon polygon , double [ ] shadowOffset , GeometryFactory factory , boolean doUnion ) { Coordinate [ ] shellCoords = polygon . getExteriorRing ( ) . getCoordinates ( ) ; Collection < Polygon > shadows = new ArrayList < Polygon > ( ) ; createShadowPolygons ( shadows , shellCoord...
Compute the shadow for a polygon
129,955
private static Geometry shadowPoint ( Point point , double [ ] shadowOffset , GeometryFactory factory ) { Coordinate startCoord = point . getCoordinate ( ) ; Coordinate offset = moveCoordinate ( startCoord , shadowOffset ) ; if ( offset . distance ( point . getCoordinate ( ) ) < 10E-3 ) { return point ; } else { startC...
Compute the shadow for a point
129,956
public static double [ ] shadowOffset ( double azimuth , double altitude , double height ) { double spread = 1 / Math . tan ( altitude ) ; return new double [ ] { - height * spread * Math . sin ( azimuth ) , - height * spread * Math . cos ( azimuth ) } ; }
Return the shadow offset in X and Y directions
129,957
private static Coordinate moveCoordinate ( Coordinate inputCoordinate , double [ ] shadowOffset ) { return new Coordinate ( inputCoordinate . x + shadowOffset [ 0 ] , inputCoordinate . y + shadowOffset [ 1 ] , 0 ) ; }
Move the input coordinate according X and Y offset
129,958
private static void createShadowPolygons ( Collection < Polygon > shadows , Coordinate [ ] coordinates , double [ ] shadow , GeometryFactory factory ) { for ( int i = 1 ; i < coordinates . length ; i ++ ) { Coordinate startCoord = coordinates [ i - 1 ] ; Coordinate endCoord = coordinates [ i ] ; Coordinate nextEnd = mo...
Create and collect shadow polygons .
129,959
public void exportTable ( Connection connection , String tableReference , File fileName , ProgressVisitor progress , String csvOptions ) 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 a CSV file
129,960
public static GeometryCollection createDT ( Geometry geometry , int flag ) throws SQLException { if ( geometry != null ) { DelaunayTriangulationBuilder triangulationBuilder = new DelaunayTriangulationBuilder ( ) ; triangulationBuilder . setSites ( geometry ) ; if ( flag == 0 ) { return getTriangles ( geometry . getFact...
Build a delaunay triangulation based on all coordinates of the geometry
129,961
public static String toKml ( Geometry geometry ) throws SQLException { StringBuilder sb = new StringBuilder ( ) ; KMLGeometry . toKMLGeometry ( geometry , sb ) ; return sb . toString ( ) ; }
Generate a KML geometry
129,962
public static String toKml ( Geometry geometry , boolean extrude , int altitudeModeEnum ) throws SQLException { StringBuilder sb = new StringBuilder ( ) ; if ( extrude ) { KMLGeometry . toKMLGeometry ( geometry , ExtrudeMode . TRUE , altitudeModeEnum , sb ) ; } else { KMLGeometry . toKMLGeometry ( geometry , ExtrudeMod...
Generates a KML geometry . Specifies the extrude and altitudeMode .
129,963
public static int getGeometryTypeFromGeometry ( Geometry geometry ) { Integer sfsGeomCode = GEOM_TYPE_TO_SFS_CODE . get ( geometry . getGeometryType ( ) . toLowerCase ( ) ) ; if ( sfsGeomCode == null ) { return GeometryTypeCodes . GEOMETRY ; } else { return sfsGeomCode ; } }
Return the sfs geometry type identifier of the provided Geometry
129,964
public static int getGeometryType ( Connection connection , TableLocation location , String fieldName ) throws SQLException { if ( fieldName == null || fieldName . isEmpty ( ) ) { List < String > geometryFields = getGeometryFields ( connection , location ) ; if ( geometryFields . isEmpty ( ) ) { throw new SQLException ...
Return the sfs geometry type identifier of the provided field of the provided table .
129,965
public static Map < String , Integer > getGeometryTypes ( Connection connection , TableLocation location ) throws SQLException { Map < String , Integer > map = new HashMap < > ( ) ; ResultSet geomResultSet = getGeometryColumnsView ( connection , location . getCatalog ( ) , location . getSchema ( ) , location . getTable...
Returns a map containing the field names as key and the SFS geometry type as value from the given table .
129,966
public static Envelope getTableEnvelope ( Connection connection , TableLocation location , String geometryField ) throws SQLException { if ( geometryField == null || geometryField . isEmpty ( ) ) { List < String > geometryFields = getGeometryFields ( connection , location ) ; if ( geometryFields . isEmpty ( ) ) { throw...
Merge the bounding box of all geometries inside the provided table .
129,967
public static PreparedStatement prepareInformationSchemaStatement ( Connection connection , String catalog , String schema , String table , String informationSchemaTable , String endQuery , String catalog_field , String schema_field , String table_field ) throws SQLException { Integer catalogIndex = null ; Integer sche...
For table containing catalog schema and table name this function create a prepared statement with a filter on this combination .
129,968
public static PreparedStatement prepareInformationSchemaStatement ( Connection connection , String catalog , String schema , String table , String informationSchemaTable , String endQuery ) throws SQLException { return prepareInformationSchemaStatement ( connection , catalog , schema , table , informationSchemaTable , ...
For table containing catalog schema and table name this function create a prepared statement with a filter on this combination . Use f_table_catalog f_table_schema f_table_name as field names .
129,969
public static List < String > getGeometryFields ( ResultSet resultSet ) throws SQLException { List < String > fieldsName = new LinkedList < > ( ) ; ResultSetMetaData meta = resultSet . getMetaData ( ) ; int columnCount = meta . getColumnCount ( ) ; for ( int i = 1 ; i <= columnCount ; i ++ ) { if ( meta . getColumnType...
Find geometry fields name of a resultSet .
129,970
public static boolean hasGeometryField ( ResultSet resultSet ) throws SQLException { ResultSetMetaData meta = resultSet . getMetaData ( ) ; int columnCount = meta . getColumnCount ( ) ; for ( int i = 1 ; i <= columnCount ; i ++ ) { if ( meta . getColumnTypeName ( i ) . equalsIgnoreCase ( "geometry" ) ) { return true ; ...
Check if the ResultSet contains a geometry field
129,971
public static Envelope getResultSetEnvelope ( ResultSet resultSet ) throws SQLException { List < String > geometryFields = getGeometryFields ( resultSet ) ; if ( geometryFields . isEmpty ( ) ) { throw new SQLException ( "This ResultSet doesn't contain any geometry field." ) ; } else { return getResultSetEnvelope ( resu...
Compute the full extend of a ResultSet using the first geometry field . If the ResultSet does not contain any geometry field throw an exception
129,972
public static Envelope getResultSetEnvelope ( ResultSet resultSet , String fieldName ) throws SQLException { Envelope aggregatedEnvelope = null ; while ( resultSet . next ( ) ) { Geometry geom = ( Geometry ) resultSet . getObject ( fieldName ) ; if ( aggregatedEnvelope != null ) { aggregatedEnvelope . expandToInclude (...
Compute the full extend of a ResultSet using a specified geometry field . If the ResultSet does not contain this geometry field throw an exception
129,973
public static int getSRID ( Connection connection , TableLocation table ) throws SQLException { ResultSet geomResultSet = getGeometryColumnsView ( connection , table . getCatalog ( ) , table . getSchema ( ) , table . getTable ( ) ) ; int srid = 0 ; while ( geomResultSet . next ( ) ) { srid = geomResultSet . getInt ( "s...
Return the SRID of the first geometry column of the input table
129,974
public static void addTableSRIDConstraint ( Connection connection , TableLocation tableLocation , int srid ) throws SQLException { if ( srid > 0 ) { connection . createStatement ( ) . execute ( String . format ( "ALTER TABLE %s ADD CHECK ST_SRID(the_geom)=%d" , tableLocation . toString ( ) , srid ) ) ; } }
Alter a table to add a SRID constraint . The srid must be greater than zero .
129,975
public MockInternetGateway createInternetGateway ( ) { MockInternetGateway ret = new MockInternetGateway ( ) ; ret . setInternetGatewayId ( "InternetGateway-" + UUID . randomUUID ( ) . toString ( ) . substring ( 0 , INTERNETGATEWAY_ID_POSTFIX_LENGTH ) ) ; allMockInternetGateways . put ( ret . getInternetGatewayId ( ) ,...
Create the mock InternetGateway .
129,976
public MockInternetGateway attachInternetGateway ( final String internetgatewayId , final String vpcId ) { if ( internetgatewayId == null ) { return null ; } MockInternetGateway ret = allMockInternetGateways . get ( internetgatewayId ) ; if ( ret != null ) { MockInternetGatewayAttachmentType internetGatewayAttachmentTy...
Attach the mock InternetGateway .
129,977
public MockInternetGateway deleteInternetGateway ( final String internetgatewayId ) { if ( internetgatewayId != null && allMockInternetGateways . containsKey ( internetgatewayId ) ) { return allMockInternetGateways . remove ( internetgatewayId ) ; } return null ; }
Delete InternetGateway .
129,978
private static long getMsFromProperty ( final String propertyName , final String propertyNameInSeconds ) { String property = PropertiesUtils . getProperty ( propertyName ) ; if ( property != null ) { return Long . parseLong ( property ) ; } return Integer . parseInt ( PropertiesUtils . getProperty ( propertyNameInSecon...
Get millisecs from properties .
129,979
public final void initializeInternalTimer ( ) { if ( ! internalTimerInitialized ) { TimerTask internalTimerTask = new TimerTask ( ) { public void run ( ) { if ( terminated ) { running = false ; booting = false ; stopping = false ; pubDns = null ; this . cancel ( ) ; onTerminated ( ) ; return ; } if ( running ) { if ( b...
Start scheduling the internal timer that controls the behaviors and states of this mock ec2 instance .
129,980
public final boolean start ( ) { if ( running || booting || stopping || terminated ) { return false ; } else { booting = true ; running = true ; onStarted ( ) ; return true ; } }
Start a stopped mock ec2 instance .
129,981
public final boolean stop ( ) { if ( booting || running ) { stopping = true ; booting = false ; onStopping ( ) ; return true ; } else { return false ; } }
Stop this ec2 instance .
129,982
public final InstanceState getInstanceState ( ) { return isTerminated ( ) ? InstanceState . TERMINATED : ( isBooting ( ) ? InstanceState . PENDING : ( isStopping ( ) ? InstanceState . STOPPING : ( isRunning ( ) ? InstanceState . RUNNING : InstanceState . STOPPED ) ) ) ; }
Get state of this mock ec2 instance .
129,983
public static List < Instance > describeAllInstances ( ) { AWSCredentials credentials = new BasicAWSCredentials ( "foo" , "bar" ) ; AmazonEC2Client amazonEC2Client = new AmazonEC2Client ( credentials ) ; String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/" ; amazonEC2Client . setEndpoint ( ec2Endpoint ) ...
Describe all mock instances within aws - mock .
129,984
public MockSubnet createSubnet ( final String cidrBlock , final String vpcId ) { MockSubnet ret = new MockSubnet ( ) ; ret . setCidrBlock ( cidrBlock ) ; ret . setSubnetId ( "subnet-" + UUID . randomUUID ( ) . toString ( ) . substring ( 0 , SUBNET_ID_POSTFIX_LENGTH ) ) ; ret . setVpcId ( vpcId ) ; allMockSubnets . put ...
Create the mock Subnet .
129,985
public MockSubnet deleteSubnet ( final String subnetId ) { if ( subnetId != null && allMockSubnets . containsKey ( subnetId ) ) { return allMockSubnets . remove ( subnetId ) ; } return null ; }
Delete Subnet .
129,986
private Set < String > parseInstanceStates ( final Map < String , String [ ] > queryParams ) { Set < String > instanceStates = new TreeSet < String > ( ) ; for ( String queryKey : queryParams . keySet ( ) ) { if ( queryKey . startsWith ( "Filter.1.Value" ) ) { for ( String state : queryParams . get ( queryKey ) ) { ins...
Parse instance states from query parameters .
129,987
private DescribeAvailabilityZonesResponseType describeAvailabilityZones ( ) { DescribeAvailabilityZonesResponseType ret = new DescribeAvailabilityZonesResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; AvailabilityZoneSetType info = new AvailabilityZoneSetType ( ) ; AvailabilityZoneItemTyp...
Handles describeAvailabilityZones request as simple as without any filters to use .
129,988
private Set < String > parseInstanceIDs ( final Map < String , String [ ] > queryParams ) { Set < String > ret = new TreeSet < String > ( ) ; Set < Map . Entry < String , String [ ] > > entries = queryParams . entrySet ( ) ; for ( Map . Entry < String , String [ ] > entry : entries ) { if ( null != entry && null != ent...
Parse instance IDs from query parameters .
129,989
protected String generateToken ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < TOKEN_MIDDLE_LEN ; i ++ ) { sb . append ( TOKEN_DICT . charAt ( random . nextInt ( TOKEN_DICT . length ( ) ) ) ) ; } return TOKEN_PREFIX + sb . toString ( ) + TOKEN_SUFFIX ; }
Generate a new token used in describeInstanceResponse while paging enabled .
129,990
private RunInstancesResponseType runInstances ( final String imageId , final String instanceType , final int minCount , final int maxCount ) { RunInstancesResponseType ret = new RunInstancesResponseType ( ) ; RunningInstancesSetType instSet = new RunningInstancesSetType ( ) ; Class < ? extends AbstractMockEc2Instance >...
Handles runInstances request with only simplified filters of imageId instanceType minCount and maxCount .
129,991
private StartInstancesResponseType startInstances ( final Set < String > instanceIDs ) { StartInstancesResponseType ret = new StartInstancesResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; InstanceStateChangeSetType changeSet = new InstanceStateChangeSetType ( ) ; changeSet . getItem ( )...
Handles startInstances request with only a simplified filter of instanceIDs .
129,992
private StopInstancesResponseType stopInstances ( final Set < String > instanceIDs ) { StopInstancesResponseType ret = new StopInstancesResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; InstanceStateChangeSetType changeSet = new InstanceStateChangeSetType ( ) ; changeSet . getItem ( ) . a...
Handles stopInstances request with only a simplified filter of instanceIDs .
129,993
private TerminateInstancesResponseType terminateInstances ( final Set < String > instanceIDs ) { TerminateInstancesResponseType ret = new TerminateInstancesResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; InstanceStateChangeSetType changeSet = new InstanceStateChangeSetType ( ) ; changeS...
Handles terminateInstances request with only a simplified filter of instanceIDs .
129,994
private DescribeImagesResponseType describeImages ( final Set < String > imageId ) { DescribeImagesResponseType ret = new DescribeImagesResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; DescribeImagesResponseInfoType info = new DescribeImagesResponseInfoType ( ) ; for ( String ami : MOCK_...
Handles describeImages request as simple as without any filters to use .
129,995
private DescribeRouteTablesResponseType describeRouteTables ( ) { DescribeRouteTablesResponseType ret = new DescribeRouteTablesResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; RouteTableSetType routeTableSet = new RouteTableSetType ( ) ; for ( Iterator < MockRouteTable > mockRouteTable =...
Handles describeRouteTables request and returns response with a route table .
129,996
private CreateRouteTableResponseType createRouteTable ( final String vpcId , final String cidrBlock ) { CreateRouteTableResponseType ret = new CreateRouteTableResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; MockRouteTable mockRouteTable = mockRouteTableController . createRouteTable ( ci...
Handles createRouteTable request to create routetable and returns response with a route table .
129,997
private CreateRouteResponseType createRoute ( final String destinationCidrBlock , final String internetGatewayId , final String routeTableId ) { CreateRouteResponseType ret = new CreateRouteResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; mockRouteTableController . createRoute ( destinat...
Handles createRoute request to create route and returns response with a route table .
129,998
private CreateVolumeResponseType createVolume ( final String volumeType , final String size , final String availabilityZone , final int iops , final String snapshotId ) { CreateVolumeResponseType ret = new CreateVolumeResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; MockVolume mockVolume...
Handles createVolume request to create volume and returns response with a volume .
129,999
private CreateSubnetResponseType createSubnet ( final String vpcId , final String cidrBlock ) { CreateSubnetResponseType ret = new CreateSubnetResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; MockSubnet mockSubnet = mockSubnetController . createSubnet ( cidrBlock , vpcId ) ; SubnetType s...
Handles createSubnet request to create Subnet and returns response with a subnet .