idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
17,000
public static Polygon createDummyPolygon ( ) { Coordinate [ ] c = new Coordinate [ ] { new Coordinate ( 0.0 , 0.0 ) , new Coordinate ( 1.0 , 1.0 ) , new Coordinate ( 1.0 , 0.0 ) , new Coordinate ( 0.0 , 0.0 ) } ; LinearRing linearRing = gf ( ) . createLinearRing ( c ) ; return gf ( ) . createPolygon ( linearRing , null...
Creates a polygon that may help out as placeholder .
17,001
public static LineString createDummyLine ( ) { Coordinate [ ] c = new Coordinate [ ] { new Coordinate ( 0.0 , 0.0 ) , new Coordinate ( 1.0 , 1.0 ) , new Coordinate ( 1.0 , 0.0 ) } ; LineString lineString = gf ( ) . createLineString ( c ) ; return lineString ; }
Creates a line that may help out as placeholder .
17,002
public static double getPolygonArea ( int [ ] x , int [ ] y , int N ) { int i , j ; double area = 0 ; for ( i = 0 ; i < N ; i ++ ) { j = ( i + 1 ) % N ; area += x [ i ] * y [ j ] ; area -= y [ i ] * x [ j ] ; } area /= 2 ; return ( area < 0 ? - area : area ) ; }
Calculates the area of a polygon from its vertices .
17,003
public static double distance3d ( Coordinate c1 , Coordinate c2 , GeodeticCalculator geodeticCalculator ) { if ( Double . isNaN ( c1 . z ) || Double . isNaN ( c2 . z ) ) { throw new IllegalArgumentException ( "Missing elevation information in the supplied coordinates." ) ; } double deltaElev = Math . abs ( c1 . z - c2 ...
Calculates the 3d distance between two coordinates that have an elevation information .
17,004
public static Polygon lines2Polygon ( boolean checkValid , LineString ... lines ) { List < Coordinate > coordinatesList = new ArrayList < Coordinate > ( ) ; List < LineString > linesList = new ArrayList < LineString > ( ) ; for ( LineString tmpLine : lines ) { linesList . add ( tmpLine ) ; } LineString currentLine = li...
Joins two lines to a polygon .
17,005
public static List < Coordinate > getCoordinatesAtInterval ( LineString line , double interval , boolean keepExisting , double startFrom , double endAt ) { if ( interval <= 0 ) { throw new IllegalArgumentException ( "Interval needs to be > 0." ) ; } double length = line . getLength ( ) ; if ( startFrom < 0 ) { startFro...
Returns the coordinates at a given interval along the line .
17,006
public static List < LineString > getSectionsAtInterval ( LineString line , double interval , double width , double startFrom , double endAt ) { if ( interval <= 0 ) { throw new IllegalArgumentException ( "Interval needs to be > 0." ) ; } double length = line . getLength ( ) ; if ( startFrom < 0 ) { startFrom = 0.0 ; }...
Returns the section line at a given interval along the line .
17,007
public static void scaleToRatio ( Rectangle2D fixed , Rectangle2D toScale , boolean doShrink ) { double origWidth = fixed . getWidth ( ) ; double origHeight = fixed . getHeight ( ) ; double toAdaptWidth = toScale . getWidth ( ) ; double toAdaptHeight = toScale . getHeight ( ) ; double scaleWidth = 0 ; double scaleHeigh...
Extends or shrinks a rectangle following the ration of a fixed one .
17,008
public static void scaleDownToFit ( Rectangle2D rectToFitIn , Rectangle2D toScale ) { double fitWidth = rectToFitIn . getWidth ( ) ; double fitHeight = rectToFitIn . getHeight ( ) ; double toScaleWidth = toScale . getWidth ( ) ; double toScaleHeight = toScale . getHeight ( ) ; if ( toScaleWidth > fitWidth ) { double fa...
Scales a rectangle down to fit inside the given one keeping the ratio .
17,009
public static Coordinate getLineWithPlaneIntersection ( Coordinate lC1 , Coordinate lC2 , Coordinate pC1 , Coordinate pC2 , Coordinate pC3 ) { double [ ] p = getPlaneCoefficientsFrom3Points ( pC1 , pC2 , pC3 ) ; double denominator = p [ 0 ] * ( lC1 . x - lC2 . x ) + p [ 1 ] * ( lC1 . y - lC2 . y ) + p [ 2 ] * ( lC1 . z...
Get the intersection coordinate between a line and plane .
17,010
public static double getAngleBetweenLinePlane ( Coordinate a , Coordinate d , Coordinate b , Coordinate c ) { double [ ] rAD = { d . x - a . x , d . y - a . y , d . z - a . z } ; double [ ] rDB = { b . x - d . x , b . y - d . y , b . z - d . z } ; double [ ] rDC = { c . x - d . x , c . y - d . y , c . z - d . z } ; dou...
Calculates the angle between line and plane .
17,011
public static double getAngleInTriangle ( double a , double b , double c ) { double angle = Math . acos ( ( a * a + b * b - c * c ) / ( 2.0 * a * b ) ) ; return angle ; }
Uses the cosine rule to find an angle in radiants of a triangle defined by the length of its sides .
17,012
public static double angleBetween3D ( Coordinate c1 , Coordinate c2 , Coordinate c3 ) { double a = distance3d ( c2 , c1 , null ) ; double b = distance3d ( c2 , c3 , null ) ; double c = distance3d ( c1 , c3 , null ) ; double angleInTriangle = getAngleInTriangle ( a , b , c ) ; double degrees = toDegrees ( angleInTriangl...
Calculates the angle in degrees between 3 3D coordinates .
17,013
@ SuppressWarnings ( "unchecked" ) public static List < LineString > mergeLinestrings ( List < LineString > multiLines ) { LineMerger lineMerger = new LineMerger ( ) ; for ( int i = 0 ; i < multiLines . size ( ) ; i ++ ) { Geometry line = multiLines . get ( i ) ; lineMerger . add ( line ) ; } Collection < Geometry > me...
Tries to merge multilines when they are snapped properly .
17,014
public static List < Polygon > createSimpleDirectionArrow ( Geometry ... geometries ) { List < Polygon > polygons = new ArrayList < > ( ) ; for ( Geometry geometry : geometries ) { for ( int i = 0 ; i < geometry . getNumGeometries ( ) ; i ++ ) { Geometry geometryN = geometry . getGeometryN ( i ) ; if ( geometryN instan...
Creates simple arrow polygons in the direction of the coordinates .
17,015
public boolean overlaps ( Location location ) { if ( location . getBeginPosition ( ) >= getBeginPosition ( ) && location . getBeginPosition ( ) <= getEndPosition ( ) ) return true ; if ( location . getBeginPosition ( ) <= getBeginPosition ( ) && location . getEndPosition ( ) >= getBeginPosition ( ) ) return true ; else...
6361 .. 6539 6363 .. 6649
17,016
private void fixRowsAndCols ( ) { rows = ( int ) Math . round ( ( north - south ) / ns_res ) ; if ( rows < 1 ) rows = 1 ; cols = ( int ) Math . round ( ( east - west ) / we_res ) ; if ( cols < 1 ) cols = 1 ; }
calculates rows and cols from the region and its resolution .
17,017
private double degreeToNumber ( String value ) { double number = - 1 ; String [ ] valueSplit = value . trim ( ) . split ( ":" ) ; if ( valueSplit . length == 3 ) { double deg = Double . parseDouble ( valueSplit [ 0 ] ) ; double min = Double . parseDouble ( valueSplit [ 1 ] ) ; double sec = Double . parseDouble ( valueS...
Transforms degree string into the decimal value .
17,018
private double [ ] xyResStringToNumbers ( String ewres , String nsres ) { double xres = - 1.0 ; double yres = - 1.0 ; if ( ewres . indexOf ( ':' ) != - 1 ) { xres = degreeToNumber ( ewres ) ; } else { xres = Double . parseDouble ( ewres ) ; } if ( nsres . indexOf ( ':' ) != - 1 ) { yres = degreeToNumber ( nsres ) ; } e...
Transforms a GRASS resolution string in metric or degree to decimal .
17,019
@ SuppressWarnings ( "nls" ) private double [ ] nsewStringsToNumbers ( String north , String south , String east , String west ) { double no = - 1.0 ; double so = - 1.0 ; double ea = - 1.0 ; double we = - 1.0 ; if ( north . indexOf ( "N" ) != - 1 || north . indexOf ( "n" ) != - 1 ) { north = north . substring ( 0 , nor...
Transforms the GRASS bounds strings in metric or degree to decimal .
17,020
public int read ( ) throws IOException { if ( lookaheadChar == UNDEFINED ) { lookaheadChar = super . read ( ) ; } lastChar = lookaheadChar ; if ( super . ready ( ) ) { lookaheadChar = super . read ( ) ; } else { lookaheadChar = UNDEFINED ; } if ( lastChar == '\n' ) { lineCounter ++ ; } return lastChar ; }
Reads the next char from the input stream .
17,021
public int read ( char [ ] buf , int off , int len ) throws IOException { if ( len == 0 ) { return 0 ; } if ( lookaheadChar == UNDEFINED ) { if ( ready ( ) ) { lookaheadChar = super . read ( ) ; } else { return - 1 ; } } if ( lookaheadChar == - 1 ) { return - 1 ; } int cOff = off ; while ( len > 0 && ready ( ) ) { if (...
Non - blocking reading of len chars into buffer buf starting at bufferposition off .
17,022
public long skip ( long n ) throws IllegalArgumentException , IOException { if ( lookaheadChar == UNDEFINED ) { lookaheadChar = super . read ( ) ; } if ( n < 0 ) { throw new IllegalArgumentException ( "negative argument not supported" ) ; } if ( n == 0 || lookaheadChar == END_OF_STREAM ) { return 0 ; } long skiped = 0 ...
Skips char in the stream
17,023
public void sort ( double [ ] values , Object [ ] valuesToFollow ) { this . valuesToSort = values ; this . valuesToFollow = valuesToFollow ; number = values . length ; monitor . beginTask ( "Sorting..." , - 1 ) ; monitor . worked ( 1 ) ; quicksort ( 0 , number - 1 ) ; monitor . done ( ) ; }
Sorts an array of values and moves with the sort a second array .
17,024
private int [ ] [ ] createStationBasinsMatrix ( double [ ] statValues , int [ ] activeStationsPerBasin ) { int [ ] [ ] stationsBasins = new int [ stationCoordinates . size ( ) ] [ basinBaricenterCoordinates . size ( ) ] ; Set < Integer > bandsIdSet = bin2StationsListMap . keySet ( ) ; Integer [ ] bandsIdArray = ( Integ...
Creates the stations per basins matrix .
17,025
private void extractFromStationFeatures ( ) throws Exception { int stationIdIndex = - 1 ; int stationElevIndex = - 1 ; pm . beginTask ( "Filling the elevation and id arrays for the stations, ordering them in ascending elevation order." , stationCoordinates . size ( ) ) ; for ( int i = 0 ; i < stationCoordinates . size ...
Fills the elevation and id arrays for the stations ordering in ascending elevation order .
17,026
public int [ ] PixelsToTile ( int px , int py ) { int tx = ( int ) Math . ceil ( px / ( ( double ) tileSize ) - 1 ) ; int ty = ( int ) Math . ceil ( py / ( ( double ) tileSize ) - 1 ) ; return new int [ ] { tx , ty } ; }
Returns a tile covering region in given pixel coordinates
17,027
public int [ ] PixelsToRaster ( int px , int py , int zoom ) { int mapSize = tileSize << zoom ; return new int [ ] { px , mapSize - py } ; }
Move the origin of pixel coordinates to top - left corner
17,028
public int ZoomForPixelSize ( int pixelSize ) { for ( int i = 0 ; i < 30 ; i ++ ) { if ( pixelSize > Resolution ( i ) ) { if ( i != 0 ) { return i - 1 ; } else { return 0 ; } } } return 0 ; }
Maximal scaledown zoom of the pyramid closest to the pixelSize
17,029
public int [ ] GoogleTile ( double lat , double lon , int zoom ) { double [ ] meters = LatLonToMeters ( lat , lon ) ; int [ ] tile = MetersToTile ( meters [ 0 ] , meters [ 1 ] , zoom ) ; return this . GoogleTile ( tile [ 0 ] , tile [ 1 ] , zoom ) ; }
Converts a lat long coordinates to Google Tile Coordinates
17,030
public String QuadTree ( int tx , int ty , int zoom ) { String quadKey = "" ; ty = ( int ) ( ( Math . pow ( 2 , zoom ) - 1 ) - ty ) ; for ( int i = zoom ; i < 0 ; i -- ) { int digit = 0 ; int mask = 1 << ( i - 1 ) ; if ( ( tx & mask ) != 0 ) { digit += 1 ; } if ( ( ty & mask ) != 0 ) { digit += 2 ; } quadKey += ( digit...
Converts TMS tile coordinates to Microsoft QuadTree
17,031
private void net ( WritableRandomIter hacksIter , WritableRandomIter netIter ) { pm . beginTask ( "Extraction of rivers of chosen order..." , nRows ) ; for ( int r = 0 ; r < nRows ; r ++ ) { for ( int c = 0 ; c < nCols ; c ++ ) { double value = hacksIter . getSampleDouble ( c , r , 0 ) ; if ( ! isNovalue ( value ) ) { ...
Return the map of the network with only the river of the choosen order .
17,032
public static ByteBuffer bytes ( String s , Charset charset ) { return ByteBuffer . wrap ( s . getBytes ( charset ) ) ; }
Encode a String in a ByteBuffer using the provided charset .
17,033
public void write ( Writer writer ) throws IOException { GFF3Writer . writeVersionPragma ( writer ) ; GFF3Writer . writeRegionPragma ( writer , entry . getPrimaryAccession ( ) , windowBeginPosition , windowEndPosition ) ; int ID = 0 ; if ( show . contains ( SHOW_GENE ) ) { locusTagGeneMap = new HashMap < String , GFF3G...
Writes the GFF3 file .
17,034
public static String trim ( String string , int pos ) { int len = string . length ( ) ; int leftPos = pos ; int rightPos = len ; for ( ; rightPos > 0 ; -- rightPos ) { char ch = string . charAt ( rightPos - 1 ) ; if ( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' ) { break ; } } for ( ; leftPos < rightPos ; ++ le...
Removes all whitespace characters from the beginning and end of the string starting from the given position .
17,035
public static String trimRight ( String string ) { for ( int i = string . length ( ) ; i > 0 ; -- i ) { if ( string . charAt ( i - 1 ) != ' ' && string . charAt ( i - 1 ) != '\t' && string . charAt ( i - 1 ) != '\n' && string . charAt ( i - 1 ) != '\r' ) { return i == string . length ( ) ? string : string . substring (...
Removes all whitespace characters from the end of the string .
17,036
public static String trimRight ( String string , int pos ) { int i = string . length ( ) ; for ( ; i > pos ; -- i ) { char charAt = string . charAt ( i - 1 ) ; if ( charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { break ; } } if ( i <= pos ) { return "" ; } return ( 0 == pos && i == string . leng...
Removes all whitespace characters from the end of the string starting from the given position .
17,037
public static String trimRight ( String string , char c ) { for ( int i = string . length ( ) ; i > 0 ; -- i ) { char charAt = string . charAt ( i - 1 ) ; if ( charAt != c && charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { return i == string . length ( ) ? string : string . substring ( 0 , i ) ;...
Removes all whitespace characters and instances of the given character from the end of the string .
17,038
public static String trimLeft ( String string ) { for ( int i = 0 ; i < string . length ( ) ; ++ i ) { char charAt = string . charAt ( i ) ; if ( charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { return i == 0 ? string : string . substring ( i ) ; } } return string ; }
Removes all whitespace characters from the beginning of the string .
17,039
public static Vector < String > split ( String string , String regex ) { Vector < String > strings = new Vector < String > ( ) ; for ( String value : string . split ( new String ( regex ) ) ) { value = value . trim ( ) ; if ( ! value . equals ( "" ) ) { strings . add ( shrink ( value ) ) ; } } return strings ; }
Split the string into values using the regular expression removes whitespace from the beginning and end of the resultant strings and replaces runs of whitespace with a single space .
17,040
public static String shrink ( String string ) { if ( string == null ) { return null ; } string = string . trim ( ) ; return SHRINK . matcher ( string ) . replaceAll ( " " ) ; }
Trims the string and replaces runs of whitespace with a single space .
17,041
public static String shrink ( String string , char c ) { if ( string == null ) { return null ; } string = string . trim ( ) ; Pattern pattern = Pattern . compile ( "\\" + String . valueOf ( c ) + "{2,}" ) ; return pattern . matcher ( string ) . replaceAll ( String . valueOf ( c ) ) ; }
Trims the string and replaces runs of whitespace with a single character .
17,042
public static String remove ( String string , char c ) { return string . replaceAll ( String . valueOf ( c ) , "" ) ; }
Removes the characters from the string .
17,043
public static Date getYear ( String string ) { if ( string == null ) { return null ; } Date date = null ; try { date = ( ( SimpleDateFormat ) year . clone ( ) ) . parse ( string ) ; } catch ( ParseException ex ) { return null ; } return date ; }
Returns the year given a string in format yyyy .
17,044
private int getNeighbours ( int [ ] src1d , int i , int ox , int oy , int d_w , int d_h ) { int x , y , result ; x = ( i % d_w ) + ox ; y = ( i / d_w ) + oy ; if ( ( x < 0 ) || ( x >= d_w ) || ( y < 0 ) || ( y >= d_h ) ) { result = 0 ; } else { result = src1d [ y * d_w + x ] & 0x000000ff ; } return result ; }
getNeighbours will get the pixel value of i s neighbour that s ox and oy away from i if the point is outside the image then 0 is returned . This version gets from source image .
17,045
private int reduce ( int a , int [ ] labels ) { if ( labels [ a ] == a ) { return a ; } else { return reduce ( labels [ a ] , labels ) ; } }
Reduces the number of labels .
17,046
public static boolean playsAll ( Role role , String ... r ) { if ( role == null ) { return false ; } for ( String s : r ) { if ( ! role . value ( ) . contains ( s ) ) { return false ; } } return true ; }
Checks if all roles are played .
17,047
public static boolean plays ( Role role , String r ) { if ( r == null ) { throw new IllegalArgumentException ( "null role" ) ; } if ( role == null ) { return false ; } return role . value ( ) . contains ( r ) ; }
Checks if one role is played .
17,048
public static boolean inRange ( Range range , double val ) { return val >= range . min ( ) && val <= range . max ( ) ; }
Check if a certain value is in range
17,049
public void close ( ) { entry . close ( ) ; getBlockCounter ( ) . clear ( ) ; getSkipTagCounter ( ) . clear ( ) ; getCache ( ) . resetOrganismCache ( ) ; getCache ( ) . resetReferenceCache ( ) ; }
Release resources used by the reader . Help the GC to cleanup the heap
17,050
public static BufferedImage ByteBufferImage ( byte [ ] data , int width , int height ) { int [ ] bandoffsets = { 0 , 1 , 2 , 3 } ; DataBufferByte dbb = new DataBufferByte ( data , data . length ) ; WritableRaster wr = Raster . createInterleavedRaster ( dbb , width , height , width * 4 , 4 , bandoffsets , null ) ; int [...
create a buffered image from a set of color triplets
17,051
public static Window getRectangleAroundPoint ( Window activeRegion , double x , double y ) { double minx = activeRegion . getRectangle ( ) . getBounds2D ( ) . getMinX ( ) ; double ewres = activeRegion . getWEResolution ( ) ; double snapx = minx + ( Math . round ( ( x - minx ) / ewres ) * ewres ) ; double miny = activeR...
return the rectangle of the cell of the active region that surrounds the given coordinates
17,052
public static void rasterizePolygonGeometry ( Window active , Geometry polygon , RasterData raster , RasterData rasterToMap , double value , IHMProgressMonitor monitor ) { GeometryFactory gFactory = new GeometryFactory ( ) ; int rows = active . getRows ( ) ; int cols = active . getCols ( ) ; double delta = active . get...
Fill polygon areas mapping on a raster
17,053
public static boolean removeGrassRasterMap ( String mapsetPath , String mapName ) throws IOException { String mappaths [ ] = filesOfRasterMap ( mapsetPath , mapName ) ; for ( int j = 0 ; j < mappaths . length ; j ++ ) { File filetoremove = new File ( mappaths [ j ] ) ; if ( filetoremove . exists ( ) ) { if ( ! FileUtil...
Given the mapsetpath and the mapname the map is removed with all its accessor files
17,054
public static double [ ] rowColToNodeboundCoordinates ( Window active , int row , int col ) { double anorth = active . getNorth ( ) ; double awest = active . getWest ( ) ; double nsres = active . getNSResolution ( ) ; double ewres = active . getWEResolution ( ) ; double [ ] nsew = new double [ 4 ] ; nsew [ 0 ] = anorth...
Transforms row and column index of the active region into an array of the coordinates of the edgaes i . e . n s e w
17,055
public static double [ ] CalculateAcadExtrusion ( double [ ] coord_in , double [ ] xtru ) { double [ ] coord_out ; double dxt0 = 0D , dyt0 = 0D , dzt0 = 0D ; double dvx1 , dvx2 , dvx3 ; double dvy1 , dvy2 , dvy3 ; double dmod , dxt , dyt , dzt ; double aux = 1D / 64D ; double aux1 = Math . abs ( xtru [ 0 ] ) ; double a...
Method that allows to apply the extrusion transformation of Autocad
17,056
public void deleteGeoTable ( String tableName ) throws Exception { String sql = "SELECT DropGeoTable('" + tableName + "');" ; try ( IHMStatement stmt = mConn . createStatement ( ) ) { stmt . execute ( sql ) ; } }
Delete a geo - table with all attached indexes and stuff .
17,057
public void runRawSqlToCsv ( String sql , File csvFile , boolean doHeader , String separator ) throws Exception { try ( BufferedWriter bw = new BufferedWriter ( new FileWriter ( csvFile ) ) ) { SpatialiteWKBReader wkbReader = new SpatialiteWKBReader ( ) ; try ( IHMStatement stmt = mConn . createStatement ( ) ; IHMResul...
Execute a query from raw sql and put the result in a csv file .
17,058
public void read ( ) throws IOException { System . out . println ( "DwgFile.read() executed ..." ) ; setDwgVersion ( ) ; if ( dwgVersion . equals ( "R13" ) ) { dwgReader = new DwgFileV14Reader ( ) ; dwgReader . read ( this ) ; } else if ( dwgVersion . equals ( "R14" ) ) { dwgReader = new DwgFileV14Reader ( ) ; dwgReade...
Reads a DWG file and put its objects in the dwgObjects Vector This method is version independent
17,059
public void calculateCadModelDwgPolylines ( ) { for ( int i = 0 ; i < dwgObjects . size ( ) ; i ++ ) { DwgObject pol = ( DwgObject ) dwgObjects . get ( i ) ; if ( pol instanceof DwgPolyline2D ) { int flags = ( ( DwgPolyline2D ) pol ) . getFlags ( ) ; int firstHandle = ( ( DwgPolyline2D ) pol ) . getFirstVertexHandle ( ...
Configure the geometry of the polylines in a DWG file from the vertex list in this DWG file . This geometry is given by an array of Points Besides manage closed polylines and polylines with bulges in a GIS Data model . It means that the arcs of the polylines will be done through a curvature parameter called bulge assoc...
17,060
public void blockManagement ( ) { Vector dwgObjectsWithoutBlocks = new Vector ( ) ; boolean addingToBlock = false ; for ( int i = 0 ; i < dwgObjects . size ( ) ; i ++ ) { try { DwgObject entity = ( DwgObject ) dwgObjects . get ( i ) ; if ( entity instanceof DwgArc && ! addingToBlock ) { dwgObjectsWithoutBlocks . add ( ...
Modify the geometry of the objects contained in the blocks of a DWG file and add these objects to the DWG object list .
17,061
public void initializeLayerTable ( ) { layerTable = new Vector ( ) ; layerNames = new Vector ( ) ; for ( int i = 0 ; i < dwgObjects . size ( ) ; i ++ ) { DwgObject obj = ( DwgObject ) dwgObjects . get ( i ) ; if ( obj instanceof DwgLayer ) { Vector layerTableRecord = new Vector ( ) ; layerTableRecord . add ( new Intege...
Initialize a new Vector that contains the DWG file layers . Each layer have three parameters . These parameters are handle name and color
17,062
public int getColorByLayer ( DwgObject entity ) { int colorByLayer = 0 ; int layer = entity . getLayerHandle ( ) ; for ( int j = 0 ; j < layerTable . size ( ) ; j ++ ) { Vector layerTableRecord = ( Vector ) layerTable . get ( j ) ; int lHandle = ( ( Integer ) layerTableRecord . get ( 0 ) ) . intValue ( ) ; if ( lHandle...
Returns the color of the layer of a DWG object
17,063
public void addDwgSectionOffset ( String key , int seek , int size ) { DwgSectionOffset dso = new DwgSectionOffset ( key , seek , size ) ; dwgSectionOffsets . add ( dso ) ; }
Add a DWG section offset to the dwgSectionOffsets vector
17,064
public int getDwgSectionOffset ( String key ) { int offset = 0 ; for ( int i = 0 ; i < dwgSectionOffsets . size ( ) ; i ++ ) { DwgSectionOffset dso = ( DwgSectionOffset ) dwgSectionOffsets . get ( i ) ; String ikey = dso . getKey ( ) ; if ( key . equals ( ikey ) ) { offset = dso . getSeek ( ) ; break ; } } return offse...
Returns the offset of DWG section given by its key
17,065
public void addDwgObjectOffset ( int handle , int offset ) { DwgObjectOffset doo = new DwgObjectOffset ( handle , offset ) ; dwgObjectOffsets . add ( doo ) ; }
Add a DWG object offset to the dwgObjectOffsets vector
17,066
protected void initValidator ( ) throws SQLException , IOException { EmblEntryValidationPlanProperty emblEntryValidationPlanProperty = new EmblEntryValidationPlanProperty ( ) ; emblEntryValidationPlanProperty . validationScope . set ( ValidationScope . getScope ( fileType ) ) ; emblEntryValidationPlanProperty . isDevMo...
Inits the validator .
17,067
protected void initWriters ( ) throws IOException { String summarywriter = prefix == null ? "VAL_SUMMARY.txt" : prefix + "_" + "VAL_SUMMARY.txt" ; String infowriter = prefix == null ? "VAL_INFO.txt" : prefix + "_" + "VAL_INFO.txt" ; String errorwriter = prefix == null ? "VAL_ERROR.txt" : prefix + "_" + "VAL_ERROR.txt" ...
separate method to instantiate so unit tests can call this
17,068
private List < ValidationPlanResult > validateFile ( File file , Writer writer ) throws IOException { List < ValidationPlanResult > messages = new ArrayList < ValidationPlanResult > ( ) ; ArrayList < Object > entryList = new ArrayList < Object > ( ) ; BufferedReader fileReader = null ; try { fileReader = new BufferedRe...
Validate file .
17,069
private void prepareReader ( BufferedReader fileReader , String fileId ) { switch ( fileType ) { case EMBL : EmblEntryReader emblReader = new EmblEntryReader ( fileReader , EmblEntryReader . Format . EMBL_FORMAT , fileId ) ; emblReader . setCheckBlockCounts ( lineCount ) ; reader = emblReader ; break ; case GENBANK : r...
Prepare reader .
17,070
private void writeResultsToFile ( ValidationPlanResult planResult ) throws IOException { for ( ValidationResult result : planResult . getResults ( ) ) { if ( result instanceof ExtendedResult ) { ExtendedResult extendedResult = ( ExtendedResult ) result ; if ( extendedResult . getExtension ( ) instanceof CdsFeatureTrans...
Write results to file .
17,071
protected Object getNextEntryFromReader ( Writer writer ) { try { parseError = false ; ValidationResult parseResult = reader . read ( ) ; if ( parseResult . getMessages ( "FT.10" ) . size ( ) >= 1 && ( fixMode || fixDiagnoseMode ) ) { parseResult . removeMessage ( "FT.10" ) ; } if ( parseResult . count ( ) != 0 ) { par...
Gets the next entry from reader .
17,072
private void setNetworkPipes ( boolean isAreaNotAllDry ) throws Exception { int length = inPipes . size ( ) ; networkPipes = new Pipe [ length ] ; SimpleFeatureIterator stationsIter = inPipes . features ( ) ; boolean existOut = false ; int tmpOutIndex = 0 ; try { int t = 0 ; while ( stationsIter . hasNext ( ) ) { Simpl...
Initializating the array .
17,073
public void verifyNet ( Pipe [ ] networkPipes , IHMProgressMonitor pm ) { boolean isOut = false ; if ( networkPipes != null ) { int length = networkPipes . length ; int kj ; for ( int i = 0 ; i < length ; i ++ ) { if ( networkPipes [ i ] . getIdPipeWhereDrain ( ) == 0 ) { isOut = true ; } if ( networkPipes [ i ] . getI...
Verify if the network is consistent .
17,074
public boolean joinLine ( ) { if ( ! isCurrentLine ( ) ) { return false ; } if ( ! isNextLine ( ) ) { return false ; } if ( ! isNextTag ( ) ) { return true ; } if ( ! isCurrentTag ( ) ) { return false ; } return getCurrentTag ( ) . equals ( getNextTag ( ) ) ; }
Returns true if the next and current lines can be joined together either because they have the same tag or because the next line does not have a tag .
17,075
public String getCurrentLine ( ) { if ( ! isCurrentLine ( ) ) { return null ; } if ( isTag ( currentLine ) ) return FlatFileUtils . trimRight ( currentLine , getTagWidth ( currentLine ) ) ; else return currentLine . trim ( ) ; }
Return current line without tag .
17,076
public String getNextLine ( ) { if ( ! isNextLine ( ) ) { return null ; } if ( isTag ( nextLine ) ) return FlatFileUtils . trimRight ( nextLine , getTagWidth ( nextLine ) ) ; else return nextLine . trim ( ) ; }
Return next line without tag .
17,077
public String getCurrentMaskedLine ( ) { if ( ! isCurrentLine ( ) ) { return null ; } StringBuilder str = new StringBuilder ( ) ; int tagWidth = getTagWidth ( currentLine ) ; for ( int i = 0 ; i < tagWidth ; ++ i ) { str . append ( " " ) ; } if ( currentLine . length ( ) > tagWidth ) { str . append ( currentLine . subs...
Return current line with tag masked with whitespace .
17,078
public String getNextMaskedLine ( ) { if ( ! isNextLine ( ) ) { return null ; } StringBuilder str = new StringBuilder ( ) ; int tagWidth = getTagWidth ( nextLine ) ; for ( int i = 0 ; i < tagWidth ; ++ i ) { str . append ( " " ) ; } if ( nextLine . length ( ) > tagWidth ) { str . append ( nextLine . substring ( tagWidt...
Return next line with tag masked with whitespace .
17,079
public String getCurrentShrinkedLine ( ) { if ( ! isCurrentLine ( ) ) { return null ; } String string = FlatFileUtils . trim ( currentLine , getTagWidth ( currentLine ) ) ; if ( string . equals ( "" ) ) { return null ; } return FlatFileUtils . shrink ( string ) ; }
Shrink and return the current line without tag .
17,080
public void propertyChange ( PropertyChangeEvent evt ) { if ( "progress" == evt . getPropertyName ( ) ) { int progress = ( Integer ) evt . getNewValue ( ) ; progressMonitor . setProgress ( progress ) ; if ( progressMonitor . isCanceled ( ) || task . isDone ( ) ) { if ( progressMonitor . isCanceled ( ) ) { task . cancel...
Invoked when task s progress property changes .
17,081
public double [ ] positionAt ( int col , int row ) { if ( isInRaster ( col , row ) ) { GridGeometry2D gridGeometry = getGridGeometry ( ) ; Coordinate coordinate = CoverageUtilities . coordinateFromColRow ( col , row , gridGeometry ) ; return new double [ ] { coordinate . x , coordinate . y } ; } return null ; }
Get world position from col row .
17,082
public int [ ] gridAt ( double x , double y ) { if ( isInRaster ( x , y ) ) { GridGeometry2D gridGeometry = getGridGeometry ( ) ; int [ ] colRowFromCoordinate = CoverageUtilities . colRowFromCoordinate ( new Coordinate ( x , y ) , gridGeometry , null ) ; return colRowFromCoordinate ; } return null ; }
Get grid col and row from a world coordinate .
17,083
public void setValueAt ( int col , int row , double value ) { if ( makeNew ) { if ( isInRaster ( col , row ) ) { ( ( WritableRandomIter ) iter ) . setSample ( col , row , 0 , value ) ; } else { throw new RuntimeException ( "Setting value outside of raster." ) ; } } else { throw new RuntimeException ( "Writing not allow...
Sets a raster value if the raster is writable .
17,084
public double [ ] surrounding ( int col , int row ) { GridNode node = new GridNode ( iter , cols , rows , xRes , yRes , col , row ) ; List < GridNode > surroundingNodes = node . getSurroundingNodes ( ) ; double [ ] surr = new double [ 8 ] ; for ( int i = 0 ; i < surroundingNodes . size ( ) ; i ++ ) { GridNode gridNode ...
Get the values of the surrounding cells .
17,085
public void write ( String path ) throws Exception { if ( makeNew ) { RasterWriter . writeRaster ( path , buildRaster ( ) ) ; } else { throw new RuntimeException ( "Only new rasters can be dumped." ) ; } }
Write the raster to file .
17,086
public static Raster read ( String path ) throws Exception { GridCoverage2D coverage2d = RasterReader . readRaster ( path ) ; Raster raster = new Raster ( coverage2d ) ; return raster ; }
Read a raster from file .
17,087
private void checkDuplicateTokens ( MutableTemplateInfo templateInfo ) throws TemplateException { List < String > allTokenNames = new ArrayList < String > ( ) ; for ( TemplateTokenInfo tokenInfo : templateInfo . tokenInfos ) { if ( allTokenNames . contains ( tokenInfo . getName ( ) ) ) { throw new TemplateException ( "...
throws error if a token name appears twice - will bail as soon as one duplicate is hit
17,088
private void processGroups ( MutableTemplateInfo template ) throws TemplateException { List < TemplateTokenGroupInfo > groupInfos = template . groupInfo ; List < String > allGroupTokens = new ArrayList < String > ( ) ; for ( TemplateTokenGroupInfo groupInfo : groupInfos ) { for ( String newToken : groupInfo . getContai...
creates a group containing all tokens not contained in any other sections - an all others group
17,089
public void shrink ( ) { if ( c . length == length ) { return ; } char [ ] newc = new char [ length ] ; System . arraycopy ( c , 0 , newc , 0 , length ) ; c = newc ; }
Shrinks the capacity of the buffer to the current length if necessary . This method involves copying the data once!
17,090
public StringBuffer toStringBuffer ( ) { StringBuffer sb = new StringBuffer ( length ) ; sb . append ( c , 0 , length ) ; return sb ; }
Converts the contents of the buffer into a StringBuffer . This method involves copying the new data once!
17,091
public static GridCoverage2D createSubCoverageFromTemplate ( GridCoverage2D template , Envelope2D subregion , Double value , WritableRaster [ ] writableRasterHolder ) { RegionMap regionMap = getRegionParamsFromGridCoverage ( template ) ; double xRes = regionMap . getXres ( ) ; double yRes = regionMap . getYres ( ) ; do...
Create a subcoverage given a template coverage and an envelope .
17,092
public static int [ ] getRegionColsRows ( GridCoverage2D gridCoverage ) { GridGeometry2D gridGeometry = gridCoverage . getGridGeometry ( ) ; GridEnvelope2D gridRange = gridGeometry . getGridRange2D ( ) ; int height = gridRange . height ; int width = gridRange . width ; int [ ] params = new int [ ] { width , height } ; ...
Get the array of rows and cols .
17,093
public static int [ ] getLoopColsRowsForSubregion ( GridCoverage2D gridCoverage , Envelope2D subregion ) throws Exception { GridGeometry2D gridGeometry = gridCoverage . getGridGeometry ( ) ; GridEnvelope2D subRegionGrid = gridGeometry . worldToGrid ( subregion ) ; int minCol = subRegionGrid . x ; int maxCol = subRegion...
Get the cols and rows ranges to use to loop the original gridcoverage .
17,094
public static int [ ] renderedImage2IntegerArray ( RenderedImage renderedImage , double multiply ) { int width = renderedImage . getWidth ( ) ; int height = renderedImage . getHeight ( ) ; int [ ] values = new int [ width * height ] ; RandomIter imageIter = RandomIterFactory . create ( renderedImage , null ) ; int inde...
Transform a double values rendered image in its integer array representation by scaling the values .
17,095
public static byte [ ] renderedImage2ByteArray ( RenderedImage renderedImage , boolean doRowsThenCols ) { int width = renderedImage . getWidth ( ) ; int height = renderedImage . getHeight ( ) ; byte [ ] values = new byte [ width * height ] ; RandomIter imageIter = RandomIterFactory . create ( renderedImage , null ) ; i...
Transform a double values rendered image in its byte array .
17,096
public static void setNovalueBorder ( WritableRaster raster ) { int width = raster . getWidth ( ) ; int height = raster . getHeight ( ) ; for ( int c = 0 ; c < width ; c ++ ) { raster . setSample ( c , 0 , 0 , doubleNovalue ) ; raster . setSample ( c , height - 1 , 0 , doubleNovalue ) ; } for ( int r = 0 ; r < height ;...
Creates a border of novalues .
17,097
public static WritableRaster replaceNovalue ( RenderedImage renderedImage , double newValue ) { WritableRaster tmpWR = ( WritableRaster ) renderedImage . getData ( ) ; RandomIter pitTmpIterator = RandomIterFactory . create ( renderedImage , null ) ; int height = renderedImage . getHeight ( ) ; int width = renderedImage...
Replace the current internal novalue with a given value .
17,098
public static ROI prepareROI ( Geometry roi , AffineTransform mt2d ) throws Exception { Geometry rasterSpaceGeometry = JTS . transform ( roi , new AffineTransform2D ( mt2d . createInverse ( ) ) ) ; Geometry simplifiedGeometry = DouglasPeuckerSimplifier . simplify ( rasterSpaceGeometry , 1 ) ; return new ROIShape ( new ...
Utility method for transforming a geometry ROI into the raster space using the provided affine transformation .
17,099
public static boolean isGrass ( String path ) { File file = new File ( path ) ; File cellFolderFile = file . getParentFile ( ) ; File mapsetFile = cellFolderFile . getParentFile ( ) ; File windFile = new File ( mapsetFile , "WIND" ) ; return cellFolderFile . getName ( ) . toLowerCase ( ) . equals ( "cell" ) && windFile...
Checks if the given path is a GRASS raster file .