idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
16,900 | public static List < LasCell > getLasCells ( ASpatialDb db , Envelope envelope , Geometry exactGeometry , boolean doPosition , boolean doIntensity , boolean doReturns , boolean doTime , boolean doColor , int limitTo ) throws Exception { List < LasCell > lasCells = new ArrayList <> ( ) ; String sql = "SELECT " + COLUMN_GEOM + "," + COLUMN_ID + "," + COLUMN_SOURCE_ID + "," + COLUMN_POINTS_COUNT ; if ( doPosition ) sql += "," + COLUMN_AVG_ELEV + "," + // COLUMN_MIN_ELEV + "," + // COLUMN_MAX_ELEV + "," + // COLUMN_POSITION_BLOB ; // if ( doIntensity ) sql += "," + COLUMN_AVG_INTENSITY + "," + // COLUMN_MIN_INTENSITY + "," + // COLUMN_MAX_INTENSITY + "," + // COLUMN_INTENS_CLASS_BLOB ; // if ( doReturns ) sql += "," + COLUMN_RETURNS_BLOB ; if ( doTime ) sql += "," + COLUMN_MIN_GPSTIME + "," + // COLUMN_MAX_GPSTIME + "," + // COLUMN_GPSTIME_BLOB ; if ( doColor ) sql += "," + COLUMN_COLORS_BLOB ; sql += " FROM " + TABLENAME ; if ( exactGeometry != null ) { sql += " WHERE " + db . getSpatialindexGeometryWherePiece ( TABLENAME , null , exactGeometry ) ; } else if ( envelope != null ) { double x1 = envelope . getMinX ( ) ; double y1 = envelope . getMinY ( ) ; double x2 = envelope . getMaxX ( ) ; double y2 = envelope . getMaxY ( ) ; sql += " WHERE " + db . getSpatialindexBBoxWherePiece ( TABLENAME , null , x1 , y1 , x2 , y2 ) ; } if ( limitTo > 0 ) { sql += " LIMIT " + limitTo ; } String _sql = sql ; IGeometryParser gp = db . getType ( ) . getGeometryParser ( ) ; return db . execOnConnection ( conn -> { try ( IHMStatement stmt = conn . createStatement ( ) ; IHMResultSet rs = stmt . executeQuery ( _sql ) ) { while ( rs . next ( ) ) { LasCell lasCell = resultSetToCell ( db , gp , doPosition , doIntensity , doReturns , doTime , doColor , rs ) ; lasCells . add ( lasCell ) ; } return lasCells ; } } ) ; } | Query the las cell table . | 642 | 6 |
16,901 | public static List < LasCell > getLasCells ( ASpatialDb db , Geometry geometry , boolean doPosition , boolean doIntensity , boolean doReturns , boolean doTime , boolean doColor ) throws Exception { List < LasCell > lasCells = new ArrayList <> ( ) ; String sql = "SELECT " + COLUMN_GEOM + "," + COLUMN_ID + "," + COLUMN_SOURCE_ID + "," + COLUMN_POINTS_COUNT ; if ( doPosition ) sql += "," + COLUMN_AVG_ELEV + "," + // COLUMN_MIN_ELEV + "," + // COLUMN_MAX_ELEV + "," + // COLUMN_POSITION_BLOB ; // if ( doIntensity ) sql += "," + COLUMN_AVG_INTENSITY + "," + // COLUMN_MIN_INTENSITY + "," + // COLUMN_MAX_INTENSITY + "," + // COLUMN_INTENS_CLASS_BLOB ; // if ( doReturns ) sql += "," + COLUMN_RETURNS_BLOB ; if ( doTime ) sql += "," + COLUMN_MIN_GPSTIME + "," + // COLUMN_MAX_GPSTIME + "," + // COLUMN_GPSTIME_BLOB ; if ( doColor ) sql += "," + COLUMN_COLORS_BLOB ; sql += " FROM " + TABLENAME ; if ( geometry != null ) { sql += " WHERE " + db . getSpatialindexGeometryWherePiece ( TABLENAME , null , geometry ) ; } String _sql = sql ; IGeometryParser gp = db . getType ( ) . getGeometryParser ( ) ; return db . execOnConnection ( conn -> { try ( IHMStatement stmt = conn . createStatement ( ) ; IHMResultSet rs = stmt . executeQuery ( _sql ) ) { while ( rs . next ( ) ) { LasCell lasCell = resultSetToCell ( db , gp , doPosition , doIntensity , doReturns , doTime , doColor , rs ) ; lasCells . add ( lasCell ) ; } return lasCells ; } } ) ; } | Query the las cell table on a geometry intersection . | 512 | 10 |
16,902 | public ValidationResult check ( Feature feature ) { result = new ValidationResult ( ) ; if ( feature == null ) { return result ; } List < Qualifier > collectionDateQualifiers = feature . getQualifiers ( Qualifier . COLLECTION_DATE_QUALIFIER_NAME ) ; if ( collectionDateQualifiers . isEmpty ( ) ) { return result ; } for ( Qualifier collectionDateQualifier : collectionDateQualifiers ) { String collectionDateValue = collectionDateQualifier . getValue ( ) ; if ( INSDC_DATE_FORMAT_PATTERN_1 . matcher ( collectionDateValue ) . matches ( ) ) { collectionDateQualifier . setValue ( "0" + collectionDateValue ) ; // convert date format "D-MON-YYYY" to "DD-MON-YYYY" reportMessage ( Severity . FIX , collectionDateQualifier . getOrigin ( ) , CollectionDateQualifierFix_ID_1 , collectionDateValue , collectionDateQualifier . getValue ( ) ) ; } if ( getEmblEntryValidationPlanProperty ( ) . validationScope . get ( ) == ValidationScope . NCBI ) { Matcher matcher = NCBI_DATE_FORMAT_PATTERN . matcher ( collectionDateValue ) ; if ( matcher . matches ( ) ) { String monthYear = "-" + matcher . group ( 2 ) + "-20" + matcher . group ( 3 ) ; collectionDateQualifier . setValue ( matcher . group ( 1 ) . length ( ) == 1 ? "0" + matcher . group ( 1 ) + monthYear : matcher . group ( 1 ) + monthYear ) ; // convert date format "D-MON-YY" or "DD-MON-YY" to "DD-MON-YYYY" reportMessage ( Severity . FIX , collectionDateQualifier . getOrigin ( ) , CollectionDateQualifierFix_ID_1 , collectionDateValue , collectionDateQualifier . getValue ( ) ) ; } } } return result ; } | DD - Mmm - YY | 441 | 7 |
16,903 | public static OSType getOperatingSystemType ( ) { if ( detectedOS == null ) { String OS = System . getProperty ( "os.name" , "generic" ) . toLowerCase ( Locale . ENGLISH ) ; if ( ( OS . indexOf ( "mac" ) >= 0 ) || ( OS . indexOf ( "darwin" ) >= 0 ) ) { detectedOS = OSType . MacOS ; } else if ( OS . indexOf ( "win" ) >= 0 ) { detectedOS = OSType . Windows ; } else if ( OS . indexOf ( "nux" ) >= 0 ) { detectedOS = OSType . Linux ; } else { detectedOS = OSType . Other ; } } return detectedOS ; } | detect the operating system from the os . name System property and cache the result | 166 | 16 |
16,904 | public static Point2D [ ] calculateGisModelCircle ( Point2D c , double r ) { Point2D [ ] pts = new Point2D [ 360 ] ; int angulo = 0 ; for ( angulo = 0 ; angulo < 360 ; angulo ++ ) { pts [ angulo ] = new Point2D . Double ( c . getX ( ) , c . getY ( ) ) ; pts [ angulo ] . setLocation ( pts [ angulo ] . getX ( ) + r * Math . sin ( angulo * Math . PI / ( double ) 180.0 ) , pts [ angulo ] . getY ( ) + r * Math . cos ( angulo * Math . PI / ( double ) 180.0 ) ) ; } return pts ; } | This method calculates an array of Point2D that represents a circle . The distance between it points is 1 angular unit | 168 | 23 |
16,905 | public static Point2D [ ] calculateGisModelBulge ( Point2D [ ] newPts , double [ ] bulges ) { Vector ptspol = new Vector ( ) ; Point2D init = new Point2D . Double ( ) ; Point2D end = new Point2D . Double ( ) ; for ( int j = 0 ; j < newPts . length ; j ++ ) { init = newPts [ j ] ; if ( j != newPts . length - 1 ) end = newPts [ j + 1 ] ; if ( bulges [ j ] == 0 || j == newPts . length - 1 || ( init . getX ( ) == end . getX ( ) && init . getY ( ) == end . getY ( ) ) ) { ptspol . add ( init ) ; } else { ArcFromBulgeCalculator arcCalculator = new ArcFromBulgeCalculator ( init , end , bulges [ j ] ) ; Vector arc = arcCalculator . getPoints ( 1 ) ; if ( bulges [ j ] < 0 ) { for ( int k = arc . size ( ) - 1 ; k >= 0 ; k -- ) { ptspol . add ( arc . get ( k ) ) ; } ptspol . remove ( ptspol . size ( ) - 1 ) ; } else { for ( int k = 0 ; k < arc . size ( ) ; k ++ ) { ptspol . add ( arc . get ( k ) ) ; } ptspol . remove ( ptspol . size ( ) - 1 ) ; } } } Point2D [ ] points = new Point2D [ ptspol . size ( ) ] ; for ( int j = 0 ; j < ptspol . size ( ) ; j ++ ) { points [ j ] = ( Point2D ) ptspol . get ( j ) ; } return points ; } | This method applies an array of bulges to an array of Point2D that defines a polyline . The result is a polyline with the input points with the addition of the points that define the new arcs added to the polyline | 404 | 47 |
16,906 | public byte [ ] seal ( byte [ ] nonce , byte [ ] plaintext ) { final XSalsa20Engine xsalsa20 = new XSalsa20Engine ( ) ; final Poly1305 poly1305 = new Poly1305 ( ) ; // initialize XSalsa20 xsalsa20 . init ( true , new ParametersWithIV ( new KeyParameter ( key ) , nonce ) ) ; // generate Poly1305 subkey final byte [ ] sk = new byte [ Keys . KEY_LEN ] ; xsalsa20 . processBytes ( sk , 0 , Keys . KEY_LEN , sk , 0 ) ; // encrypt plaintext final byte [ ] out = new byte [ plaintext . length + poly1305 . getMacSize ( ) ] ; xsalsa20 . processBytes ( plaintext , 0 , plaintext . length , out , poly1305 . getMacSize ( ) ) ; // hash ciphertext and prepend mac to ciphertext poly1305 . init ( new KeyParameter ( sk ) ) ; poly1305 . update ( out , poly1305 . getMacSize ( ) , plaintext . length ) ; poly1305 . doFinal ( out , 0 ) ; return out ; } | Encrypt a plaintext using the given key and nonce . | 259 | 13 |
16,907 | public Optional < byte [ ] > open ( byte [ ] nonce , byte [ ] ciphertext ) { final XSalsa20Engine xsalsa20 = new XSalsa20Engine ( ) ; final Poly1305 poly1305 = new Poly1305 ( ) ; // initialize XSalsa20 xsalsa20 . init ( false , new ParametersWithIV ( new KeyParameter ( key ) , nonce ) ) ; // generate mac subkey final byte [ ] sk = new byte [ Keys . KEY_LEN ] ; xsalsa20 . processBytes ( sk , 0 , sk . length , sk , 0 ) ; // hash ciphertext poly1305 . init ( new KeyParameter ( sk ) ) ; final int len = Math . max ( ciphertext . length - poly1305 . getMacSize ( ) , 0 ) ; poly1305 . update ( ciphertext , poly1305 . getMacSize ( ) , len ) ; final byte [ ] calculatedMAC = new byte [ poly1305 . getMacSize ( ) ] ; poly1305 . doFinal ( calculatedMAC , 0 ) ; // extract mac final byte [ ] presentedMAC = new byte [ poly1305 . getMacSize ( ) ] ; System . arraycopy ( ciphertext , 0 , presentedMAC , 0 , Math . min ( ciphertext . length , poly1305 . getMacSize ( ) ) ) ; // compare macs if ( ! MessageDigest . isEqual ( calculatedMAC , presentedMAC ) ) { return Optional . empty ( ) ; } // decrypt ciphertext final byte [ ] plaintext = new byte [ len ] ; xsalsa20 . processBytes ( ciphertext , poly1305 . getMacSize ( ) , plaintext . length , plaintext , 0 ) ; return Optional . of ( plaintext ) ; } | Decrypt a ciphertext using the given key and nonce . | 382 | 13 |
16,908 | public byte [ ] nonce ( ) { final byte [ ] nonce = new byte [ NONCE_SIZE ] ; final SecureRandom random = new SecureRandom ( ) ; random . nextBytes ( nonce ) ; return nonce ; } | Generates a random nonce . | 50 | 7 |
16,909 | public byte [ ] nonce ( byte [ ] message ) { final byte [ ] n1 = new byte [ 16 ] ; final byte [ ] n2 = new byte [ 16 ] ; final SecureRandom random = new SecureRandom ( ) ; random . nextBytes ( n1 ) ; random . nextBytes ( n2 ) ; final Blake2bDigest blake2b = new Blake2bDigest ( key , NONCE_SIZE , n1 , n2 ) ; blake2b . update ( message , message . length , 0 ) ; final byte [ ] nonce = new byte [ NONCE_SIZE ] ; blake2b . doFinal ( nonce , 0 ) ; return nonce ; } | Generates a random nonce which is guaranteed to be unique even if the process s PRNG is exhausted or compromised . | 151 | 24 |
16,910 | public Object get ( int row , int col ) { return ( dstore == null ) ? null : dstore . get ( row , col ) ; } | Returns the data of this objects row and column cell . | 32 | 11 |
16,911 | public static boolean go_downstream ( int [ ] colRow , double flowdirection ) { int n = ( int ) flowdirection ; if ( n == 10 ) { return true ; } else if ( n < 1 || n > 9 ) { return false ; } else { colRow [ 1 ] += DIR [ n ] [ 0 ] ; colRow [ 0 ] += DIR [ n ] [ 1 ] ; return true ; } } | Moves one pixel downstream . | 92 | 6 |
16,912 | public static boolean sourcesNet ( RandomIter flowIterator , int [ ] colRow , int num , RandomIter netNum ) { int [ ] [ ] dir = { { 0 , 0 , 0 } , { 1 , 0 , 5 } , { 1 , - 1 , 6 } , { 0 , - 1 , 7 } , { - 1 , - 1 , 8 } , { - 1 , 0 , 1 } , { - 1 , 1 , 2 } , { 0 , 1 , 3 } , { 1 , 1 , 4 } } ; if ( flowIterator . getSampleDouble ( colRow [ 0 ] , colRow [ 1 ] , 0 ) <= 10.0 && flowIterator . getSampleDouble ( colRow [ 0 ] , colRow [ 1 ] , 0 ) > 0.0 ) { for ( int k = 1 ; k <= 8 ; k ++ ) { if ( flowIterator . getSampleDouble ( colRow [ 0 ] + dir [ k ] [ 0 ] , colRow [ 1 ] + dir [ k ] [ 1 ] , 0 ) == dir [ k ] [ 2 ] && netNum . getSampleDouble ( colRow [ 0 ] + dir [ k ] [ 0 ] , colRow [ 1 ] + dir [ k ] [ 1 ] , 0 ) == num ) { return false ; } } return true ; } else { return false ; } } | Controls if the considered point is a source in the network map . | 288 | 14 |
16,913 | public static double [ ] vectorizeDoubleMatrix ( RenderedImage input ) { double [ ] U = new double [ input . getWidth ( ) * input . getHeight ( ) ] ; RandomIter inputRandomIter = RandomIterFactory . create ( input , null ) ; int j = 0 ; for ( int i = 0 ; i < input . getHeight ( ) * input . getWidth ( ) ; i = i + input . getWidth ( ) ) { double tmp [ ] = new double [ input . getWidth ( ) ] ; for ( int k = 0 ; k < input . getWidth ( ) ; k ++ ) { tmp [ k ] = inputRandomIter . getSampleDouble ( k , j , 0 ) ; } System . arraycopy ( tmp , 0 , U , i , input . getWidth ( ) ) ; j ++ ; } return U ; } | Takes a input raster and vectorializes it . | 182 | 12 |
16,914 | public static double calculateNthMoment ( double [ ] values , int validValues , double mean , double momentOrder , IHMProgressMonitor pm ) { double moment = 0.0 ; double n = 0.0 ; if ( momentOrder == 1.0 ) { for ( int i = 0 ; i < validValues ; i ++ ) { if ( ! isNovalue ( values [ i ] ) ) { moment += values [ i ] ; n ++ ; } } if ( n >= 1 ) { moment /= n ; } } else if ( momentOrder == 2.0 ) { // FIXME this needs to be checked, variance doesn't give negative values for ( int i = 0 ; i < validValues ; i ++ ) { if ( ! isNovalue ( values [ i ] ) ) { moment += ( values [ i ] ) * ( values [ i ] ) ; n ++ ; } } if ( n >= 1 ) { moment = ( moment / n - mean * mean ) ; } } else { for ( int i = 0 ; i < validValues ; i ++ ) { if ( ! isNovalue ( values [ i ] ) ) { moment += pow ( ( values [ i ] - mean ) , momentOrder ) ; n ++ ; } } if ( n >= 1 ) { moment /= n ; } } if ( n == 0 ) { pm . errorMessage ( "No valid data were processed, setting moment value to zero." ) ; moment = 0.0 ; } return moment ; } | Calculates the nth moment of a set of values . | 319 | 13 |
16,915 | public static WritableRaster extractSubbasins ( WritableRandomIter flowIter , RandomIter netIter , WritableRandomIter netNumberIter , int rows , int cols , IHMProgressMonitor pm ) { for ( int r = 0 ; r < rows ; r ++ ) { for ( int c = 0 ; c < cols ; c ++ ) { if ( ! isNovalue ( netIter . getSampleDouble ( c , r , 0 ) ) ) flowIter . setSample ( c , r , 0 , FlowNode . OUTLET ) ; } } WritableRaster subbasinWR = CoverageUtilities . createWritableRaster ( cols , rows , Integer . class , null , null ) ; WritableRandomIter subbasinIter = RandomIterFactory . createWritable ( subbasinWR , null ) ; markHillSlopeWithLinkValue ( flowIter , netNumberIter , subbasinIter , cols , rows , pm ) ; try { for ( int r = 0 ; r < rows ; r ++ ) { for ( int c = 0 ; c < cols ; c ++ ) { int netValue = netIter . getSample ( c , r , 0 ) ; int netNumberValue = netNumberIter . getSample ( c , r , 0 ) ; if ( ! isNovalue ( netValue ) ) { subbasinIter . setSample ( c , r , 0 , netNumberValue ) ; } if ( NumericsUtilities . dEq ( netNumberValue , 0 ) ) { netNumberIter . setSample ( c , r , 0 , HMConstants . intNovalue ) ; } int subbValue = subbasinIter . getSample ( c , r , 0 ) ; if ( NumericsUtilities . dEq ( subbValue , 0 ) ) subbasinIter . setSample ( c , r , 0 , HMConstants . intNovalue ) ; } } } finally { subbasinIter . done ( ) ; } return subbasinWR ; } | Extract the subbasins of a raster map . | 437 | 12 |
16,916 | public static void markHillSlopeWithLinkValue ( RandomIter flowIter , RandomIter attributeIter , WritableRandomIter markedIter , int cols , int rows , IHMProgressMonitor pm ) { pm . beginTask ( "Marking the hillslopes with the channel value..." , rows ) ; for ( int r = 0 ; r < rows ; r ++ ) { for ( int c = 0 ; c < cols ; c ++ ) { FlowNode flowNode = new FlowNode ( flowIter , cols , rows , c , r ) ; if ( flowNode . isHeadingOutside ( ) ) { // ignore single cells on borders that exit anyway continue ; } if ( flowNode . isMarkedAsOutlet ( ) ) { double attributeValue = flowNode . getDoubleValueFromMap ( attributeIter ) ; flowNode . setDoubleValueInMap ( markedIter , attributeValue ) ; continue ; } if ( flowNode . isValid ( ) && flowNode . isSource ( ) ) { /* * run down to the net to find the * attribute map content on the net */ double attributeValue = doubleNovalue ; FlowNode runningNode = flowNode . goDownstream ( ) ; int runningRow = - 1 ; int runningCol = - 1 ; while ( runningNode != null && runningNode . isValid ( ) ) { runningRow = runningNode . row ; runningCol = runningNode . col ; if ( runningNode . isMarkedAsOutlet ( ) ) { attributeValue = runningNode . getDoubleValueFromMap ( attributeIter ) ; break ; } runningNode = runningNode . goDownstream ( ) ; } if ( ! isNovalue ( attributeValue ) ) { // run down marking the hills runningNode = flowNode ; while ( runningNode != null && runningNode . isValid ( ) ) { runningNode . setDoubleValueInMap ( markedIter , attributeValue ) ; if ( runningNode . isMarkedAsOutlet ( ) ) { break ; } runningNode = runningNode . goDownstream ( ) ; } } else { throw new ModelsIllegalargumentException ( "Could not find a value of the attributes map in the channel after point: " + runningCol + "/" + runningRow + ". Are you sure that everything leads to a channel or outlet?" , "MODELSENGINE" , pm ) ; } } } pm . worked ( 1 ) ; } pm . done ( ) ; } | Marks a map on the hillslope with the values on the channel of an attribute map . | 513 | 20 |
16,917 | public static boolean isSourcePixel ( RandomIter flowIter , int col , int row ) { double flowDirection = flowIter . getSampleDouble ( col , row , 0 ) ; if ( flowDirection < 9.0 && flowDirection > 0.0 ) { for ( int k = 1 ; k <= 8 ; k ++ ) { if ( flowIter . getSampleDouble ( col + dirIn [ k ] [ 1 ] , row + dirIn [ k ] [ 0 ] , 0 ) == dirIn [ k ] [ 2 ] ) { return false ; } } return true ; } else { return false ; } } | Verifies if the point is a source pixel in the supplied flow raster . | 132 | 16 |
16,918 | public static double width_interpolate ( double [ ] [ ] data , double x , int nx , int ny ) { int rows = data . length ; double xuno = 0 , xdue = 0 , yuno = 0 , ydue = 0 , y = 0 ; // if 0, interpolate between 0 and the first value of data if ( x >= 0 && x < data [ 0 ] [ nx ] ) { xuno = 0 ; xdue = data [ 0 ] [ nx ] ; yuno = 0 ; ydue = data [ 0 ] [ ny ] ; y = ( ( ydue - yuno ) / ( xdue - xuno ) ) * ( x - xuno ) + yuno ; } // if it is less than 0 and bigger than the maximum, throw error if ( x > data [ ( rows - 1 ) ] [ nx ] || x < 0 ) { throw new RuntimeException ( MessageFormat . format ( "Error in the interpolation algorithm: entering with x = {0} (min = 0.0 max = {1}" , x , data [ ( rows - 1 ) ] [ nx ] ) ) ; } /* trovo i valori limite entro i quali effettuo l'interpolazione lineare */ for ( int i = 0 ; i < rows - 1 ; i ++ ) { if ( x > data [ i ] [ nx ] && x <= data [ ( i + 1 ) ] [ nx ] ) { xuno = data [ i ] [ nx ] ; xdue = data [ ( i + 1 ) ] [ nx ] ; yuno = data [ i ] [ ny ] ; ydue = data [ ( i + 1 ) ] [ ny ] ; y = ( ( ydue - yuno ) / ( xdue - xuno ) ) * ( x - xuno ) + yuno ; } } return y ; } | Linear interpolation between two values | 412 | 7 |
16,919 | public static double henderson ( double [ ] [ ] data , int tp ) { int rows = data . length ; int j = 1 , n = 0 ; double dt = 0 , muno , mdue , a , b , x , y , ydue , s_uno , s_due , smax = 0 , tstar ; for ( int i = 1 ; i < rows ; i ++ ) { if ( data [ i ] [ 0 ] + tp <= data [ ( rows - 1 ) ] [ 0 ] ) { /** * ***trovo parametri geometrici del segmento di retta y=muno * x+a****** */ muno = ( data [ i ] [ 1 ] - data [ ( i - 1 ) ] [ 1 ] ) / ( data [ i ] [ 0 ] - data [ ( i - 1 ) ] [ 0 ] ) ; a = data [ i ] [ 1 ] - ( data [ i ] [ 0 ] + tp ) * muno ; /** * ***trovo i valori di x per l'intersezione tra y=(muno x+tp)+a * e y=mdue x+b ****** */ for ( j = 1 ; j <= ( rows - 1 ) ; j ++ ) { mdue = ( data [ j ] [ 1 ] - data [ ( j - 1 ) ] [ 1 ] ) / ( data [ j ] [ 0 ] - data [ ( j - 1 ) ] [ 0 ] ) ; b = data [ j ] [ 1 ] - data [ j ] [ 0 ] * mdue ; x = ( a - b ) / ( mdue - muno ) ; y = muno * x + a ; if ( x >= data [ ( j - 1 ) ] [ 0 ] && x <= data [ j ] [ 0 ] && x - tp >= data [ ( i - 1 ) ] [ 0 ] && x - tp <= data [ i ] [ 0 ] ) { ydue = width_interpolate ( data , x - tp , 0 , 1 ) ; n ++ ; s_uno = width_interpolate ( data , x - tp , 0 , 2 ) ; s_due = width_interpolate ( data , x , 0 , 2 ) ; if ( s_due - s_uno > smax ) { smax = s_due - s_uno ; dt = x - tp ; tstar = x ; } } } } } return dt ; } | Interpolates the width function in a given tp . | 535 | 12 |
16,920 | public static double gamma ( double x ) { double tmp = ( x - 0.5 ) * log ( x + 4.5 ) - ( x + 4.5 ) ; double ser = 1.0 + 76.18009173 / ( x + 0 ) - 86.50532033 / ( x + 1 ) + 24.01409822 / ( x + 2 ) - 1.231739516 / ( x + 3 ) + 0.00120858003 / ( x + 4 ) - 0.00000536382 / ( x + 5 ) ; double gamma = exp ( tmp + log ( ser * sqrt ( 2 * PI ) ) ) ; return gamma ; } | The Gamma function . | 146 | 4 |
16,921 | public static WritableRaster sumDownstream ( RandomIter flowIter , RandomIter mapToSumIter , int width , int height , Double upperThreshold , Double lowerThreshold , IHMProgressMonitor pm ) { final int [ ] point = new int [ 2 ] ; WritableRaster summedMapWR = CoverageUtilities . createWritableRaster ( width , height , null , null , null ) ; WritableRandomIter summedMapIter = RandomIterFactory . createWritable ( summedMapWR , null ) ; double uThres = Double . POSITIVE_INFINITY ; if ( upperThreshold != null ) { uThres = upperThreshold ; } double lThres = Double . NEGATIVE_INFINITY ; if ( lowerThreshold != null ) { lThres = lowerThreshold ; } pm . beginTask ( "Calculating downstream sum..." , height ) ; for ( int r = 0 ; r < height ; r ++ ) { for ( int c = 0 ; c < width ; c ++ ) { double mapToSumValue = mapToSumIter . getSampleDouble ( c , r , 0 ) ; if ( ! isNovalue ( flowIter . getSampleDouble ( c , r , 0 ) ) && // mapToSumValue < uThres && // mapToSumValue > lThres // ) { point [ 0 ] = c ; point [ 1 ] = r ; while ( flowIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) < 9 && // ! isNovalue ( flowIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) ) && ( checkRange ( mapToSumIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) , uThres , lThres ) ) ) { double sumValue = summedMapIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) + mapToSumIter . getSampleDouble ( c , r , 0 ) ; summedMapIter . setSample ( point [ 0 ] , point [ 1 ] , 0 , sumValue ) ; // FlowNode flowNode = new FlowNode(flowIter, width, height, point[0], // point[1]); // FlowNode downStreamNode = flowNode.goDownstream(); // if (downStreamNode != null) { // if (!downStreamNode.isMarkedAsOutlet()) { // point[0] = downStreamNode.col; // point[1] = downStreamNode.row; // } // } else { // return null; // } if ( ! go_downstream ( point , flowIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) ) ) return null ; } if ( ! isNovalue ( flowIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) ) ) { double summedMapValue = summedMapIter . getSampleDouble ( point [ 0 ] , point [ 1 ] , 0 ) ; if ( ! isNovalue ( summedMapValue ) ) { double sumValue = summedMapValue + mapToSumIter . getSampleDouble ( c , r , 0 ) ; summedMapIter . setSample ( point [ 0 ] , point [ 1 ] , 0 , sumValue ) ; } } } else { summedMapIter . setSample ( c , r , 0 , doubleNovalue ) ; } } pm . worked ( 1 ) ; } pm . done ( ) ; return summedMapWR ; } | Calculates the sum of the values of a specified quantity from every point to the outlet . | 754 | 19 |
16,922 | public static double [ ] calcInverseSunVector ( double [ ] sunVector ) { double m = Math . max ( Math . abs ( sunVector [ 0 ] ) , Math . abs ( sunVector [ 1 ] ) ) ; return new double [ ] { - sunVector [ 0 ] / m , - sunVector [ 1 ] / m , - sunVector [ 2 ] / m } ; } | Calculating the inverse of the sun vector . | 83 | 10 |
16,923 | public static double [ ] calcNormalSunVector ( double [ ] sunVector ) { double [ ] normalSunVector = new double [ 3 ] ; normalSunVector [ 2 ] = Math . sqrt ( Math . pow ( sunVector [ 0 ] , 2 ) + Math . pow ( sunVector [ 1 ] , 2 ) ) ; normalSunVector [ 0 ] = - sunVector [ 0 ] * sunVector [ 2 ] / normalSunVector [ 2 ] ; normalSunVector [ 1 ] = - sunVector [ 1 ] * sunVector [ 2 ] / normalSunVector [ 2 ] ; return normalSunVector ; } | Calculating the normal to the sun vector . | 129 | 10 |
16,924 | public static double scalarProduct ( double [ ] a , double [ ] b ) { double c = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { c = c + a [ i ] * b [ i ] ; } return c ; } | Compute the dot product . | 59 | 6 |
16,925 | public static WritableRaster calculateFactor ( int h , int w , double [ ] sunVector , double [ ] inverseSunVector , double [ ] normalSunVector , WritableRaster demWR , double dx ) { double casx = 1e6 * sunVector [ 0 ] ; double casy = 1e6 * sunVector [ 1 ] ; int f_i = 0 ; int f_j = 0 ; if ( casx <= 0 ) { f_i = 0 ; } else { f_i = w - 1 ; } if ( casy <= 0 ) { f_j = 0 ; } else { f_j = h - 1 ; } WritableRaster sOmbraWR = CoverageUtilities . createWritableRaster ( w , h , null , null , 1.0 ) ; int j = f_j ; for ( int i = 0 ; i < sOmbraWR . getWidth ( ) ; i ++ ) { shadow ( i , j , sOmbraWR , demWR , dx , normalSunVector , inverseSunVector ) ; } int i = f_i ; for ( int k = 0 ; k < sOmbraWR . getHeight ( ) ; k ++ ) { shadow ( i , k , sOmbraWR , demWR , dx , normalSunVector , inverseSunVector ) ; } return sOmbraWR ; } | Evaluate the shadow map calling the shadow method . | 297 | 11 |
16,926 | private static WritableRaster shadow ( int i , int j , WritableRaster tmpWR , WritableRaster demWR , double res , double [ ] normalSunVector , double [ ] inverseSunVector ) { int n = 0 ; double zcompare = - Double . MAX_VALUE ; double dx = ( inverseSunVector [ 0 ] * n ) ; double dy = ( inverseSunVector [ 1 ] * n ) ; int nCols = tmpWR . getWidth ( ) ; int nRows = tmpWR . getHeight ( ) ; int idx = ( int ) Math . round ( i + dx ) ; int jdy = ( int ) Math . round ( j + dy ) ; double vectorToOrigin [ ] = new double [ 3 ] ; while ( idx >= 0 && idx <= nCols - 1 && jdy >= 0 && jdy <= nRows - 1 ) { vectorToOrigin [ 0 ] = dx * res ; vectorToOrigin [ 1 ] = dy * res ; int tmpY = ( int ) ( j + dy ) ; if ( tmpY < 0 ) { tmpY = 0 ; } else if ( tmpY > nRows ) { tmpY = nRows - 1 ; } int tmpX = ( int ) ( i + dx ) ; if ( tmpX < 0 ) { tmpX = 0 ; } else if ( tmpY > nCols ) { tmpX = nCols - 1 ; } vectorToOrigin [ 2 ] = demWR . getSampleDouble ( idx , jdy , 0 ) ; // vectorToOrigin[2] = (pitRandomIter.getSampleDouble(idx, jdy, 0) + // pitRandomIter // .getSampleDouble(tmpX, tmpY, 0)) / 2; double zprojection = scalarProduct ( vectorToOrigin , normalSunVector ) ; if ( ( zprojection < zcompare ) ) { tmpWR . setSample ( idx , jdy , 0 , 0 ) ; } else { zcompare = zprojection ; } n = n + 1 ; dy = ( inverseSunVector [ 1 ] * n ) ; dx = ( inverseSunVector [ 0 ] * n ) ; idx = ( int ) Math . round ( i + dx ) ; jdy = ( int ) Math . round ( j + dy ) ; } return tmpWR ; } | Evaluate the shadow map . | 509 | 7 |
16,927 | public static double meanDoublematrixColumn ( double [ ] [ ] matrix , int column ) { double mean ; mean = 0 ; int length = matrix . length ; for ( int i = 0 ; i < length ; i ++ ) { mean += matrix [ i ] [ column ] ; } return mean / length ; } | Return the mean of a column of a matrix . | 66 | 10 |
16,928 | public static double varianceDoublematrixColumn ( double [ ] [ ] matrix , int column , double mean ) { double variance ; variance = 0 ; for ( int i = 0 ; i < matrix . length ; i ++ ) { variance += ( matrix [ i ] [ column ] - mean ) * ( matrix [ i ] [ column ] - mean ) ; } return variance / matrix . length ; } | Return the variance of a column of a matrix . | 82 | 10 |
16,929 | public static double sumDoublematrixColumns ( int coolIndex , double [ ] [ ] matrixToSum , double [ ] [ ] resultMatrix , int firstRowIndex , int lastRowIndex , IHMProgressMonitor pm ) { double maximum ; maximum = 0 ; if ( matrixToSum . length != resultMatrix . length ) { pm . errorMessage ( msg . message ( "trentoP.error.matrix" ) ) ; //$NON-NLS-1$ throw new ArithmeticException ( msg . message ( "trentoP.error.matrix" ) ) ; //$NON-NLS-1$ } if ( firstRowIndex < 0 || lastRowIndex < firstRowIndex ) { pm . errorMessage ( msg . message ( "trentoP.error.nCol" ) ) ; //$NON-NLS-1$ throw new ArithmeticException ( msg . message ( "trentoP.error.nCol" ) ) ; //$NON-NLS-1$ } for ( int i = 0 ; i < matrixToSum . length ; ++ i ) { resultMatrix [ i ] [ coolIndex ] = 0 ; /* Initializes element */ for ( int j = firstRowIndex ; j <= lastRowIndex ; ++ j ) { resultMatrix [ i ] [ coolIndex ] += matrixToSum [ i ] [ j ] ; } if ( resultMatrix [ i ] [ coolIndex ] >= maximum ) /* Saves maximum value */ { maximum = resultMatrix [ i ] [ coolIndex ] ; } } return maximum ; } | Sum columns . | 337 | 3 |
16,930 | public Long getRelativePosition ( Long position ) { long relativePosition = 0L ; for ( Location location : locations ) { if ( location instanceof RemoteLocation ) { relativePosition += location . getLength ( ) ; } else { if ( position < location . getBeginPosition ( ) || position > location . getEndPosition ( ) ) { relativePosition += location . getLength ( ) ; } else { if ( location . isComplement ( ) ) { relativePosition += ( location . getEndPosition ( ) - position + 1 ) ; } else { relativePosition += ( position - location . getBeginPosition ( ) + 1 ) ; } if ( isComplement ( ) ) { relativePosition = getLength ( ) - relativePosition + 1 ; } return relativePosition ; } } } return null ; } | Returns the sequence position relative to the compound location . | 167 | 10 |
16,931 | protected boolean concatOr ( boolean ... statements ) { boolean isTrue = statements [ 0 ] ; for ( int i = 1 ; i < statements . length ; i ++ ) { isTrue = isTrue || statements [ i ] ; } return isTrue ; } | Utility method to concatenate conditions with or . | 54 | 11 |
16,932 | protected void checkNull ( Object ... objects ) { for ( Object object : objects ) { if ( object == null ) { throw new ModelsIllegalargumentException ( "Mandatory input argument is missing. Check your syntax..." , this . getClass ( ) . getSimpleName ( ) , pm ) ; } } } | Checks if the passed objects are all ! = null and if one is null throws Exception . | 65 | 19 |
16,933 | protected void checkFileExists ( String ... existingFilePath ) { StringBuilder sb = null ; for ( String filePath : existingFilePath ) { File file = new File ( filePath ) ; if ( ! file . exists ( ) ) { if ( sb == null ) { sb = new StringBuilder ( ) ; sb . append ( "The following file doesn't seem to exist: " ) ; } sb . append ( "\n\t" ) . append ( file . getAbsolutePath ( ) ) ; } } if ( sb != null ) throw new ModelsIllegalargumentException ( sb . toString ( ) , this . getClass ( ) . getSimpleName ( ) , pm ) ; } | Checks if passed path strings exist on the filesystem . If not an Exception is thrown . | 154 | 18 |
16,934 | protected String checkWorkingFolderInPath ( String filePath ) { if ( filePath . contains ( HMConstants . WORKINGFOLDER ) ) { return null ; } return filePath ; } | Checks if a passed path contains the workingfolder constant . If yes it is set to null . | 41 | 20 |
16,935 | public GridCoverage2D getRaster ( String source ) throws Exception { if ( source == null || source . trim ( ) . length ( ) == 0 ) return null ; OmsRasterReader reader = new OmsRasterReader ( ) ; reader . pm = pm ; reader . file = source ; reader . process ( ) ; GridCoverage2D geodata = reader . outRaster ; return geodata ; } | Fast default reading of raster from definition . | 92 | 9 |
16,936 | public SimpleFeatureCollection getVector ( String source ) throws Exception { if ( source == null || source . trim ( ) . length ( ) == 0 ) return null ; OmsVectorReader reader = new OmsVectorReader ( ) ; reader . pm = pm ; reader . file = source ; reader . process ( ) ; SimpleFeatureCollection fc = reader . outVector ; return fc ; } | Fast default reading of vector from definition . | 82 | 8 |
16,937 | public void dumpRaster ( GridCoverage2D raster , String source ) throws Exception { if ( raster == null || source == null ) return ; OmsRasterWriter writer = new OmsRasterWriter ( ) ; writer . pm = pm ; writer . inRaster = raster ; writer . file = source ; writer . process ( ) ; } | Fast default writing of raster to source . | 77 | 9 |
16,938 | public void dumpVector ( SimpleFeatureCollection vector , String source ) throws Exception { if ( vector == null || source == null ) return ; OmsVectorWriter writer = new OmsVectorWriter ( ) ; writer . pm = pm ; writer . file = source ; writer . inVector = vector ; writer . process ( ) ; } | Fast default writing of vector to source . | 68 | 8 |
16,939 | public void setParameter ( String key , Object obj ) { if ( key . equals ( "novalue" ) ) { //$NON-NLS-1$ novalue = obj ; } else if ( key . equals ( "matrixtype" ) ) { //$NON-NLS-1$ Integer dmtype = ( Integer ) obj ; matrixType = dmtype . intValue ( ) ; } } | utility to set particular parameters | 92 | 6 |
16,940 | private ByteBuffer readHeader ( RandomAccessFile ds ) throws IOException { /* * the first byte defines the number of bytes are used to describe the row addresses in the * header (once it was sizeof(long) in grass but then it was turned to an offset (that * brought to reading problems in JGrass whenever the offset was != 4). */ int first = ds . read ( ) ; ByteBuffer fileHeader = ByteBuffer . allocate ( 1 + first * fileWindow . getRows ( ) + first ) ; ds . seek ( 0 ) ; /* Read header */ ds . read ( fileHeader . array ( ) ) ; return fileHeader ; } | Reads the header part of the file into memory | 140 | 10 |
16,941 | private long [ ] getRowAddressesFromHeader ( ByteBuffer header ) { /* * Jump over the no more needed first byte (used in readHeader to define the header size) */ byte firstbyte = header . get ( ) ; /* Read the data row addresses inside the file */ long [ ] adrows = new long [ fileWindow . getRows ( ) + 1 ] ; if ( firstbyte == 4 ) { for ( int i = 0 ; i <= fileWindow . getRows ( ) ; i ++ ) { adrows [ i ] = header . getInt ( ) ; } } else if ( firstbyte == 8 ) { for ( int i = 0 ; i <= fileWindow . getRows ( ) ; i ++ ) { adrows [ i ] = header . getLong ( ) ; } } else { // problems } return adrows ; } | Extract the row addresses from the header information of the file | 180 | 12 |
16,942 | private void getMapRow ( int currentrow , ByteBuffer rowdata , boolean iscompressed ) throws IOException , DataFormatException { // if (logger.isDebugEnabled()) // { // logger.debug("ACCESSING THE FILE at row: " + currentrow + // ", rasterMapType = " + rasterMapType + // ", numberOfBytesPerValue = " + numberOfBytesPerValue + // ", iscompressed = " + iscompressed); // } if ( iscompressed ) { /* Compressed maps */ if ( rasterMapType == - 2 ) { /* Compressed double map */ readCompressedFPRowByNumber ( rowdata , currentrow , addressesofrows , cellFile , numberOfBytesPerValue ) ; } else if ( rasterMapType == - 1 ) { /* Compressed floating point map */ readCompressedFPRowByNumber ( rowdata , currentrow , addressesofrows , cellFile , numberOfBytesPerValue ) ; } else if ( rasterMapType > 0 ) { /* Compressed integer map */ readCompressedIntegerRowByNumber ( rowdata , currentrow , addressesofrows , cellFile ) ; } else { // if (logger.isDebugEnabled()) // logger.error("format not double nor float"); } } else { if ( rasterMapType < 0 ) { /* Uncompressed floating point map */ readUncompressedFPRowByNumber ( rowdata , currentrow , cellFile , numberOfBytesPerValue ) ; } else if ( rasterMapType > 0 ) { /* Uncompressed integer map */ readUncompressedIntegerRowByNumber ( rowdata , currentrow , cellFile ) ; } else { // if (logger.isDebugEnabled()) // logger.error("Unknown case, iscompressed=" + iscompressed // + ", compressed=" + compressed + ", rasterMapType=" // + rasterMapType); } } return ; } | read a row of the map from the active region | 414 | 10 |
16,943 | private void readCompressedFPRowByNumber ( ByteBuffer rowdata , int rn , long [ ] adrows , RandomAccessFile thefile , int typeBytes ) throws DataFormatException , IOException { int offset = ( int ) ( adrows [ rn + 1 ] - adrows [ rn ] ) ; /* * The fact that the file is compressed does not mean that the row is compressed. If the * first byte is 0 (49), then the row is compressed, otherwise (first byte = 48) the row has * to be read in simple XDR uncompressed format. */ byte [ ] tmp = new byte [ offset - 1 ] ; thefile . seek ( adrows [ rn ] ) ; int firstbyte = ( thefile . read ( ) & 0xff ) ; if ( firstbyte == 49 ) { /* The row is compressed. */ // thefile.seek((long) adrows[rn] + 1); thefile . read ( tmp , 0 , offset - 1 ) ; Inflater decompresser = new Inflater ( ) ; decompresser . setInput ( tmp , 0 , tmp . length ) ; decompresser . inflate ( rowdata . array ( ) ) ; decompresser . end ( ) ; } else if ( firstbyte == 48 ) { /* The row is NOT compressed */ // thefile.seek((long) (adrows[rn])); // if (thefile.read() == 48) // { // thefile.seek((long) (adrows[rn] + 1)); thefile . read ( rowdata . array ( ) , 0 , offset - 1 ) ; // } } } | read a row of data from a compressed floating point map | 350 | 11 |
16,944 | private void readUncompressedFPRowByNumber ( ByteBuffer rowdata , int rn , RandomAccessFile thefile , int typeBytes ) throws IOException , DataFormatException { int datanumber = fileWindow . getCols ( ) * typeBytes ; thefile . seek ( ( rn * datanumber ) ) ; thefile . read ( rowdata . array ( ) ) ; } | read a row of data from an uncompressed floating point map | 85 | 12 |
16,945 | private void readCompressedIntegerRowByNumber ( ByteBuffer rowdata , int rn , long [ ] adrows , RandomAccessFile thefile ) throws IOException , DataFormatException { int offset = ( int ) ( adrows [ rn + 1 ] - adrows [ rn ] ) ; thefile . seek ( adrows [ rn ] ) ; /* * Read how many bytes the values are ex 1 => if encoded: 1 byte for the value and one byte * for the count = 2 2 => if encoded: 2 bytes for the value and one byte for the count = 3 * etc... etc */ int bytespervalue = ( thefile . read ( ) & 0xff ) ; ByteBuffer cell = ByteBuffer . allocate ( bytespervalue ) ; int cellValue = 0 ; /* Create the buffer in which read the compressed row */ byte [ ] tmp = new byte [ offset - 1 ] ; thefile . read ( tmp ) ; ByteBuffer tmpBuffer = ByteBuffer . wrap ( tmp ) ; tmpBuffer . order ( ByteOrder . nativeOrder ( ) ) ; /* * Create the buffer in which read the decompressed row. The final decompressed row will * always contain 4-byte integer values */ if ( ( offset - 1 ) == ( bytespervalue * fileWindow . getCols ( ) ) ) { /* There is no compression in this row */ for ( int i = 0 ; i < offset - 1 ; i = i + bytespervalue ) { /* Read the value */ tmpBuffer . get ( cell . array ( ) ) ; /* * Integers can be of 1, 2, or 4 bytes. As rasterBuffer expects 4 byte integers we * need to pad them with 0's. The order of the padding is determined by the * ByteOrder of the buffer. */ if ( bytespervalue == 1 ) { cellValue = ( cell . get ( 0 ) & 0xff ) ; } else if ( bytespervalue == 2 ) { cellValue = cell . getShort ( 0 ) ; } else if ( bytespervalue == 4 ) { cellValue = cell . getInt ( 0 ) ; } // if (logger.isDebugEnabled()) logger.debug("tmpint=" + tmpint // ); rowdata . putInt ( cellValue ) ; } } else { /* * If the row is compressed, then the values appear in pairs (like couples a party). The * couple is composed of the count and the value value (WARNING: this can be more than * one byte). Therefore, knowing the length of the compressed row we can calculate the * number of couples. */ int couples = ( offset - 1 ) / ( 1 + bytespervalue ) ; for ( int i = 0 ; i < couples ; i ++ ) { /* Read the count of values */ int count = ( tmpBuffer . get ( ) & 0xff ) ; /* Read the value */ tmpBuffer . get ( cell . array ( ) ) ; /* * Integers can be of 1, 2, or 4 bytes. As rasterBuffer expects 4 byte integers we * need to pad them with 0's. The order of the padding is determined by the * ByteOrder of the buffer. */ if ( bytespervalue == 1 ) { cellValue = ( cell . get ( 0 ) & 0xff ) ; } else if ( bytespervalue == 2 ) { cellValue = cell . getShort ( 0 ) ; } else if ( bytespervalue == 4 ) { cellValue = cell . getInt ( 0 ) ; } /* * Now write the cell value the required number of times to the raster row data * buffer. */ for ( int j = 0 ; j < count ; j ++ ) { // // if (logger.isDebugEnabled()) logger.debug(" " + // tmpint); rowdata . putInt ( cellValue ) ; } } } } | read a row of data from a compressed integer point map | 804 | 11 |
16,946 | private void readUncompressedIntegerRowByNumber ( ByteBuffer rowdata , int rn , RandomAccessFile thefile ) throws IOException , DataFormatException { int cellValue = 0 ; ByteBuffer cell = ByteBuffer . allocate ( rasterMapType ) ; /* The number of bytes that are inside a row in the file. */ int filerowsize = fileWindow . getCols ( ) * rasterMapType ; /* Position the file pointer to read the row */ thefile . seek ( ( rn * filerowsize ) ) ; /* Read the row of data from the file */ ByteBuffer tmpBuffer = ByteBuffer . allocate ( filerowsize ) ; thefile . read ( tmpBuffer . array ( ) ) ; /* * Transform the rasterMapType-size-values to a standard 4 bytes integer value */ while ( tmpBuffer . hasRemaining ( ) ) { // read the value tmpBuffer . get ( cell . array ( ) ) ; /* * Integers can be of 1, 2, or 4 bytes. As rasterBuffer expects 4 byte integers we need * to pad them with 0's. The order of the padding is determined by the ByteOrder of the * buffer. */ if ( rasterMapType == 1 ) { cellValue = ( cell . get ( 0 ) & 0xff ) ; } else if ( rasterMapType == 2 ) { cellValue = cell . getShort ( 0 ) ; } else if ( rasterMapType == 4 ) { cellValue = cell . getInt ( 0 ) ; } // if (logger.isDebugEnabled()) logger.debug("tmpint=" + cellValue // ); rowdata . putInt ( cellValue ) ; } } | read a row of data from an uncompressed integer map | 359 | 11 |
16,947 | public Color getColorFor ( double value ) { if ( value <= min ) { return colors [ 0 ] ; } else if ( value >= max ) { return colors [ colors . length - 1 ] ; } else { for ( int i = 1 ; i < colors . length ; i ++ ) { double v1 = values [ i - 1 ] ; double v2 = values [ i ] ; if ( value < v2 ) { double v = ( value - v1 ) / ( v2 - v1 ) ; Color interpolateColor = interpolateColor ( colors [ i - 1 ] , colors [ i ] , ( float ) v ) ; return interpolateColor ; } } return colors [ colors . length - 1 ] ; } } | Get the color of the defined table by its value . | 154 | 11 |
16,948 | public static Color interpolateColor ( Color color1 , Color color2 , float fraction ) { float int2Float = 1f / 255f ; fraction = Math . min ( fraction , 1f ) ; fraction = Math . max ( fraction , 0f ) ; float r1 = color1 . getRed ( ) * int2Float ; float g1 = color1 . getGreen ( ) * int2Float ; float b1 = color1 . getBlue ( ) * int2Float ; float a1 = color1 . getAlpha ( ) * int2Float ; float r2 = color2 . getRed ( ) * int2Float ; float g2 = color2 . getGreen ( ) * int2Float ; float b2 = color2 . getBlue ( ) * int2Float ; float a2 = color2 . getAlpha ( ) * int2Float ; float deltaR = r2 - r1 ; float deltaG = g2 - g1 ; float deltaB = b2 - b1 ; float deltaA = a2 - a1 ; float red = r1 + ( deltaR * fraction ) ; float green = g1 + ( deltaG * fraction ) ; float blue = b1 + ( deltaB * fraction ) ; float alpha = a1 + ( deltaA * fraction ) ; red = Math . min ( red , 1f ) ; red = Math . max ( red , 0f ) ; green = Math . min ( green , 1f ) ; green = Math . max ( green , 0f ) ; blue = Math . min ( blue , 1f ) ; blue = Math . max ( blue , 0f ) ; alpha = Math . min ( alpha , 1f ) ; alpha = Math . max ( alpha , 0f ) ; return new Color ( red , green , blue , alpha ) ; } | Interpolate a color at a given fraction between 0 and 1 . | 384 | 14 |
16,949 | public void addSeries ( String seriesName , double [ ] x , double [ ] y ) { XYSeries series = new XYSeries ( seriesName ) ; for ( int i = 0 ; i < x . length ; i ++ ) { series . add ( x [ i ] , y [ i ] ) ; } dataset . addSeries ( series ) ; } | Add a new series by name and data . | 74 | 9 |
16,950 | public static long insertLasSource ( ASpatialDb db , int srid , int levels , double resolution , double factor , Polygon polygon , String name , double minElev , double maxElev , double minIntens , double maxIntens ) throws Exception { String sql = "INSERT INTO " + TABLENAME // + " (" + COLUMN_GEOM + "," + COLUMN_NAME + "," + COLUMN_RESOLUTION + "," // + COLUMN_FACTOR + "," + COLUMN_LEVELS + "," + COLUMN_MINZ + "," + COLUMN_MAXZ + "," + COLUMN_MININTENSITY + "," + COLUMN_MAXINTENSITY + // ") VALUES (ST_GeomFromText(?, " + srid + "),?,?,?,?,?,?,?,?)" ; return db . execOnConnection ( connection -> { try ( IHMPreparedStatement pStmt = connection . prepareStatement ( sql , Statement . RETURN_GENERATED_KEYS ) ) { pStmt . setString ( 1 , polygon . toText ( ) ) ; pStmt . setString ( 2 , name ) ; pStmt . setDouble ( 3 , resolution ) ; pStmt . setDouble ( 4 , factor ) ; pStmt . setInt ( 5 , levels ) ; pStmt . setDouble ( 6 , minElev ) ; pStmt . setDouble ( 7 , maxElev ) ; pStmt . setDouble ( 8 , minIntens ) ; pStmt . setDouble ( 9 , maxIntens ) ; pStmt . executeUpdate ( ) ; IHMResultSet rs = pStmt . getGeneratedKeys ( ) ; rs . next ( ) ; long generatedId = rs . getLong ( 1 ) ; return generatedId ; } } ) ; } | Insert values in the table | 418 | 5 |
16,951 | public static void updateMinMaxIntensity ( ASpatialDb db , long sourceId , double minIntens , double maxIntens ) throws Exception { String sql = "UPDATE " + TABLENAME // + " SET " + COLUMN_MININTENSITY + "=" + minIntens + ", " + COLUMN_MAXINTENSITY + "=" + maxIntens + // " WHERE " + COLUMN_ID + "=" + sourceId ; db . executeInsertUpdateDeleteSql ( sql ) ; } | Update the intensity values . | 115 | 5 |
16,952 | public static List < LasSource > getLasSources ( ASpatialDb db ) throws Exception { List < LasSource > sources = new ArrayList <> ( ) ; String sql = "SELECT " + COLUMN_GEOM + "," + COLUMN_ID + "," + COLUMN_NAME + "," + COLUMN_RESOLUTION + "," + COLUMN_FACTOR + "," + COLUMN_LEVELS + "," + COLUMN_MINZ + "," + COLUMN_MAXZ + "," + COLUMN_MININTENSITY + "," + COLUMN_MAXINTENSITY + " FROM " + TABLENAME ; return db . execOnConnection ( connection -> { IGeometryParser gp = db . getType ( ) . getGeometryParser ( ) ; try ( IHMStatement stmt = connection . createStatement ( ) ; IHMResultSet rs = stmt . executeQuery ( sql ) ) { while ( rs . next ( ) ) { LasSource lasSource = new LasSource ( ) ; int i = 1 ; Geometry geometry = gp . fromResultSet ( rs , i ++ ) ; if ( geometry instanceof Polygon ) { Polygon polygon = ( Polygon ) geometry ; lasSource . polygon = polygon ; lasSource . id = rs . getLong ( i ++ ) ; lasSource . name = rs . getString ( i ++ ) ; lasSource . resolution = rs . getDouble ( i ++ ) ; lasSource . levelFactor = rs . getDouble ( i ++ ) ; lasSource . levels = rs . getInt ( i ++ ) ; lasSource . minElev = rs . getDouble ( i ++ ) ; lasSource . maxElev = rs . getDouble ( i ++ ) ; lasSource . minIntens = rs . getDouble ( i ++ ) ; lasSource . maxIntens = rs . getDouble ( i ++ ) ; sources . add ( lasSource ) ; } } return sources ; } } ) ; } | Query the las sources table . | 438 | 6 |
16,953 | public static boolean isLasDatabase ( ASpatialDb db ) throws Exception { if ( ! db . hasTable ( TABLENAME ) || ! db . hasTable ( LasCellsTable . TABLENAME ) ) { return false ; } return true ; } | Checks if the db is a las database readable by HortonMachine . | 58 | 14 |
16,954 | protected Point limitPointToWorldWindow ( Point point ) { Rectangle viewport = this . getWwd ( ) . getView ( ) . getViewport ( ) ; int x = point . x ; if ( x < viewport . x ) x = viewport . x ; if ( x > viewport . x + viewport . width ) x = viewport . x + viewport . width ; int y = point . y ; if ( y < viewport . y ) y = viewport . y ; if ( y > viewport . y + viewport . height ) y = viewport . y + viewport . height ; return new Point ( x , y ) ; } | Limits the specified point s x and y coordinates to the World Window s viewport and returns a new point with the limited coordinates . For example if the World Window s viewport rectangle is x = 0 y = 0 width = 100 height = 100 and the point s coordinates are x = 50 y = 200 this returns a new point with coordinates x = 50 y = 100 . If the specified point is already inside the World Window s viewport this returns a new point with the same x and y coordinates as the specified point . | 144 | 106 |
16,955 | public static void show ( BufferedImage image , String title , boolean modal ) { JDialog f = new JDialog ( ) ; f . add ( new ImageViewer ( image ) , BorderLayout . CENTER ) ; f . setTitle ( title ) ; f . setIconImage ( ImageCache . getInstance ( ) . getBufferedImage ( ImageCache . HORTONMACHINE_FRAME_ICON ) ) ; f . setModal ( modal ) ; f . pack ( ) ; int h = image . getHeight ( ) ; int w = image . getWidth ( ) ; if ( h > w ) { f . setSize ( new Dimension ( 600 , 800 ) ) ; } else { f . setSize ( new Dimension ( 800 , 600 ) ) ; } f . setLocationRelativeTo ( null ) ; // Center on screen f . setVisible ( true ) ; f . setDefaultCloseOperation ( JDialog . DISPOSE_ON_CLOSE ) ; f . getRootPane ( ) . registerKeyboardAction ( e -> { f . dispose ( ) ; } , KeyStroke . getKeyStroke ( KeyEvent . VK_ESCAPE , 0 ) , JComponent . WHEN_IN_FOCUSED_WINDOW ) ; } | Opens a JDialog with the image viewer in it . | 274 | 12 |
16,956 | public static List < Image > getImagesList ( IHMConnection connection ) throws Exception { List < Image > images = new ArrayList < Image > ( ) ; String sql = "select " + // ImageTableFields . COLUMN_ID . getFieldName ( ) + "," + // ImageTableFields . COLUMN_LON . getFieldName ( ) + "," + // ImageTableFields . COLUMN_LAT . getFieldName ( ) + "," + // ImageTableFields . COLUMN_ALTIM . getFieldName ( ) + "," + // ImageTableFields . COLUMN_TS . getFieldName ( ) + "," + // ImageTableFields . COLUMN_AZIM . getFieldName ( ) + "," + // ImageTableFields . COLUMN_TEXT . getFieldName ( ) + "," + // ImageTableFields . COLUMN_NOTE_ID . getFieldName ( ) + "," + // ImageTableFields . COLUMN_IMAGEDATA_ID . getFieldName ( ) + // " from " + TABLE_IMAGES ; try ( IHMStatement statement = connection . createStatement ( ) ; IHMResultSet rs = statement . executeQuery ( sql ) ; ) { statement . setQueryTimeout ( 30 ) ; // set timeout to 30 sec. while ( rs . next ( ) ) { long id = rs . getLong ( 1 ) ; double lon = rs . getDouble ( 2 ) ; double lat = rs . getDouble ( 3 ) ; double altim = rs . getDouble ( 4 ) ; long ts = rs . getLong ( 5 ) ; double azim = rs . getDouble ( 6 ) ; String text = rs . getString ( 7 ) ; long noteId = rs . getLong ( 8 ) ; long imageDataId = rs . getLong ( 9 ) ; Image image = new Image ( id , text , lon , lat , altim , azim , imageDataId , noteId , ts ) ; images . add ( image ) ; } } return images ; } | Get the list of Images from the db . | 451 | 9 |
16,957 | public static byte [ ] getImageData ( IHMConnection connection , long imageDataId ) throws Exception { String sql = "select " + // ImageDataTableFields . COLUMN_IMAGE . getFieldName ( ) + // " from " + TABLE_IMAGE_DATA + " where " + // ImageDataTableFields . COLUMN_ID . getFieldName ( ) + " = " + imageDataId ; try ( IHMStatement statement = connection . createStatement ( ) ; IHMResultSet rs = statement . executeQuery ( sql ) ; ) { statement . setQueryTimeout ( 30 ) ; // set timeout to 30 sec. if ( rs . next ( ) ) { byte [ ] bytes = rs . getBytes ( 1 ) ; return bytes ; } } return null ; } | Get Image data from data id . | 169 | 7 |
16,958 | public static void convert ( SquareMatrix sm ) { for ( int r = 0 ; r < sm . nRows ; ++ r ) { for ( int c = 0 ; c < sm . nCols ; ++ c ) { sm . values [ r ] [ c ] = ( r == c ) ? 1 : 0 ; } } } | Convert a square matrix into an identity matrix . | 71 | 10 |
16,959 | public static SimpleFeatureCollection createFeatureCollection ( SimpleFeature ... features ) { DefaultFeatureCollection fcollection = new DefaultFeatureCollection ( ) ; for ( SimpleFeature feature : features ) { fcollection . add ( feature ) ; } return fcollection ; } | Create a featurecollection from a vector of features | 51 | 9 |
16,960 | public static Object getAttributeCaseChecked ( SimpleFeature feature , String field ) { Object attribute = feature . getAttribute ( field ) ; if ( attribute == null ) { attribute = feature . getAttribute ( field . toLowerCase ( ) ) ; if ( attribute != null ) return attribute ; attribute = feature . getAttribute ( field . toUpperCase ( ) ) ; if ( attribute != null ) return attribute ; // alright, last try, search for it SimpleFeatureType featureType = feature . getFeatureType ( ) ; field = findAttributeName ( featureType , field ) ; if ( field != null ) { return feature . getAttribute ( field ) ; } } return attribute ; } | Getter for attributes of a feature . | 143 | 8 |
16,961 | public static String findAttributeName ( SimpleFeatureType featureType , String field ) { List < AttributeDescriptor > attributeDescriptors = featureType . getAttributeDescriptors ( ) ; for ( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { String name = attributeDescriptor . getLocalName ( ) ; if ( name . toLowerCase ( ) . equals ( field . toLowerCase ( ) ) ) { return name ; } } return null ; } | Find the name of an attribute case insensitive . | 104 | 9 |
16,962 | public static QueryResult featureCollection2QueryResult ( SimpleFeatureCollection featureCollection ) { List < AttributeDescriptor > attributeDescriptors = featureCollection . getSchema ( ) . getAttributeDescriptors ( ) ; QueryResult queryResult = new QueryResult ( ) ; int count = 0 ; for ( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { if ( ! ( attributeDescriptor instanceof GeometryDescriptor ) ) { String fieldName = attributeDescriptor . getLocalName ( ) ; String type = attributeDescriptor . getType ( ) . getBinding ( ) . toString ( ) ; queryResult . names . add ( fieldName ) ; queryResult . types . add ( type ) ; count ++ ; } } SimpleFeatureIterator featureIterator = featureCollection . features ( ) ; while ( featureIterator . hasNext ( ) ) { SimpleFeature f = featureIterator . next ( ) ; Geometry geometry = ( Geometry ) f . getDefaultGeometry ( ) ; queryResult . geometries . add ( geometry ) ; Object [ ] dataRow = new Object [ count ] ; int index = 0 ; for ( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { if ( ! ( attributeDescriptor instanceof GeometryDescriptor ) ) { String fieldName = attributeDescriptor . getLocalName ( ) ; Object attribute = f . getAttribute ( fieldName ) ; if ( attribute == null ) { attribute = "" ; } dataRow [ index ++ ] = attribute ; } } queryResult . data . add ( dataRow ) ; } return queryResult ; } | Utility to convert a featurecollection to a queryresult format . | 348 | 13 |
16,963 | private static URI createUriFromName ( String name ) { if ( name == null ) { throw new NullPointerException ( "name" ) ; } try { return new URI ( name ) ; } catch ( final URISyntaxException e ) { throw new IllegalArgumentException ( "Invalid name: " + name , e ) ; } } | Creates a URI from a source file name . | 74 | 10 |
16,964 | public static void addNote ( Connection connection , long id , double lon , double lat , double altim , long timestamp , String text , String form ) throws Exception { String insertSQL = "INSERT INTO " + TableDescriptions . TABLE_NOTES + "(" + // TableDescriptions . NotesTableFields . COLUMN_ID . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_LAT . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_LON . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_ALTIM . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_TS . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_TEXT . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_FORM . getFieldName ( ) + ", " + // TableDescriptions . NotesTableFields . COLUMN_ISDIRTY . getFieldName ( ) + // ") VALUES" + "(?,?,?,?,?,?,?,?)" ; try ( PreparedStatement writeStatement = connection . prepareStatement ( insertSQL ) ) { writeStatement . setLong ( 1 , id ) ; writeStatement . setDouble ( 2 , lat ) ; writeStatement . setDouble ( 3 , lon ) ; writeStatement . setDouble ( 4 , altim ) ; writeStatement . setLong ( 5 , timestamp ) ; writeStatement . setString ( 6 , text ) ; writeStatement . setString ( 7 , form ) ; writeStatement . setInt ( 8 , 1 ) ; writeStatement . executeUpdate ( ) ; } } | Add a new note to the database . | 404 | 8 |
16,965 | public static List < Note > getNotesList ( IHMConnection connection , float [ ] nswe ) throws Exception { String query = "SELECT " + // NotesTableFields . COLUMN_ID . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_LON . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_LAT . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_ALTIM . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_TEXT . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_TS . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_DESCRIPTION . getFieldName ( ) + // " FROM " + TABLE_NOTES ; if ( nswe != null ) { query = query + " WHERE (lon BETWEEN XXX AND XXX) AND (lat BETWEEN XXX AND XXX)" ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 2 ] ) ) ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 3 ] ) ) ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 1 ] ) ) ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 0 ] ) ) ; } List < Note > notes = new ArrayList <> ( ) ; try ( IHMStatement statement = connection . createStatement ( ) ; IHMResultSet rs = statement . executeQuery ( query ) ; ) { statement . setQueryTimeout ( 30 ) ; // set timeout to 30 sec. while ( rs . next ( ) ) { Note note = new Note ( ) ; note . id = rs . getLong ( 1 ) ; note . lon = rs . getDouble ( 2 ) ; note . lat = rs . getDouble ( 3 ) ; note . altim = rs . getDouble ( 4 ) ; note . simpleText = rs . getString ( 5 ) ; note . timeStamp = rs . getLong ( 6 ) ; note . description = rs . getString ( 7 ) ; notes . add ( note ) ; } } return notes ; } | Get the collected notes from the database inside a given bound . | 499 | 12 |
16,966 | private boolean isAtLeastOneAssignable ( String main , Class < ? > ... classes ) { for ( Class < ? > clazz : classes ) { if ( clazz . getCanonicalName ( ) . equals ( main ) ) { return true ; } } return false ; } | Checks if one class is assignable from at least one of the others . | 62 | 16 |
16,967 | public void sort ( double [ ] values , double [ ] valuesToFollow ) { this . valuesToSortDouble = values ; this . valuesToFollowDouble = valuesToFollow ; number = values . length ; monitor . beginTask ( "Sorting..." , - 1 ) ; monitor . worked ( 1 ) ; quicksort ( 0 , number - 1 ) ; monitor . done ( ) ; } | Sorts an array of double values and moves with the sort a second array . | 82 | 16 |
16,968 | public void sort ( float [ ] values , float [ ] valuesToFollow ) { this . valuesToSortFloat = values ; this . valuesToFollowFloat = valuesToFollow ; number = values . length ; monitor . beginTask ( "Sorting..." , - 1 ) ; monitor . worked ( 1 ) ; quicksortFloat ( 0 , number - 1 ) ; monitor . done ( ) ; } | Sorts an array of float values and moves with the sort a second array . | 83 | 16 |
16,969 | public float nextCentral ( ) { // Average 12 uniformly-distributed random values. float sum = 0.0f ; for ( int j = 0 ; j < 12 ; ++ j ) sum += gen . nextFloat ( ) ; // Subtract 6 to center about 0. return stddev * ( sum - 6 ) + mean ; } | Compute the next random value using the Central Limit Theorem which states that the averages of sets of uniformly - distributed random values are normally distributed . | 72 | 29 |
16,970 | public float nextPolar ( ) { // If there's a saved value, return it. if ( haveNextPolar ) { haveNextPolar = false ; return nextPolar ; } float u1 , u2 , r ; // point coordinates and their radius do { // u1 and u2 will be uniformly-distributed // random values in [-1, +1). u1 = 2 * gen . nextFloat ( ) - 1 ; u2 = 2 * gen . nextFloat ( ) - 1 ; // Want radius r inside the unit circle. r = u1 * u1 + u2 * u2 ; } while ( r >= 1 ) ; // Factor incorporates the standard deviation. float factor = ( float ) ( stddev * Math . sqrt ( - 2 * Math . log ( r ) / r ) ) ; // v1 and v2 are normally-distributed random values. float v1 = factor * u1 + mean ; float v2 = factor * u2 + mean ; // Save v1 for next time. nextPolar = v1 ; haveNextPolar = true ; return v2 ; } | Compute the next randomn value using the polar algorithm . Requires two uniformly - distributed random values in [ - 1 + 1 ) . Actually computes two random values and saves the second one for the next invokation . | 238 | 45 |
16,971 | public float nextRatio ( ) { float u , v , x , xx ; do { // u and v are two uniformly-distributed random values // in [0, 1), and u != 0. while ( ( u = gen . nextFloat ( ) ) == 0 ) ; // try again if 0 v = gen . nextFloat ( ) ; float y = C1 * ( v - 0.5f ) ; // y coord of point (u, y) x = y / u ; // ratio of point's coords xx = x * x ; } while ( ( xx > 5f - C2 * u ) // quick acceptance && ( ( xx >= C3 / u + 1.4f ) || // quick rejection ( xx > ( float ) ( - 4 * Math . log ( u ) ) ) ) // final test ) ; return stddev * x + mean ; } | Compute the next random value using the ratio algorithm . Requires two uniformly - distributed random values in [ 0 1 ) . | 187 | 24 |
16,972 | 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 . | 112 | 12 |
16,973 | 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 . | 85 | 11 |
16,974 | 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 . | 99 | 14 |
16,975 | 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 . z ) ; double projectedDistance ; if ( geodeticCalculator != null ) { geodeticCalculator . setStartingGeographicPoint ( c1 . x , c1 . y ) ; geodeticCalculator . setDestinationGeographicPoint ( c2 . x , c2 . y ) ; projectedDistance = geodeticCalculator . getOrthodromicDistance ( ) ; } else { projectedDistance = c1 . distance ( c2 ) ; } double distance = NumericsUtilities . pythagoras ( projectedDistance , deltaElev ) ; return distance ; } | Calculates the 3d distance between two coordinates that have an elevation information . | 224 | 16 |
16,976 | 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 = linesList . get ( 0 ) ; linesList . remove ( 0 ) ; while ( linesList . size ( ) > 0 ) { Coordinate [ ] coordinates = currentLine . getCoordinates ( ) ; List < Coordinate > tmpList = Arrays . asList ( coordinates ) ; coordinatesList . addAll ( tmpList ) ; Point thePoint = currentLine . getEndPoint ( ) ; double minDistance = Double . MAX_VALUE ; LineString minDistanceLine = null ; boolean needFlip = false ; for ( LineString tmpLine : linesList ) { Point tmpStartPoint = tmpLine . getStartPoint ( ) ; double distance = thePoint . distance ( tmpStartPoint ) ; if ( distance < minDistance ) { minDistance = distance ; minDistanceLine = tmpLine ; needFlip = false ; } Point tmpEndPoint = tmpLine . getEndPoint ( ) ; distance = thePoint . distance ( tmpEndPoint ) ; if ( distance < minDistance ) { minDistance = distance ; minDistanceLine = tmpLine ; needFlip = true ; } } linesList . remove ( minDistanceLine ) ; if ( needFlip ) { minDistanceLine = ( LineString ) minDistanceLine . reverse ( ) ; } currentLine = minDistanceLine ; } // add last Coordinate [ ] coordinates = currentLine . getCoordinates ( ) ; List < Coordinate > tmpList = Arrays . asList ( coordinates ) ; coordinatesList . addAll ( tmpList ) ; coordinatesList . add ( coordinatesList . get ( 0 ) ) ; LinearRing linearRing = gf ( ) . createLinearRing ( coordinatesList . toArray ( new Coordinate [ 0 ] ) ) ; Polygon polygon = gf ( ) . createPolygon ( linearRing , null ) ; if ( checkValid ) { if ( ! polygon . isValid ( ) ) { return null ; } } return polygon ; } | Joins two lines to a polygon . | 488 | 9 |
16,977 | 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 ) { startFrom = 0.0 ; } if ( endAt < 0 ) { endAt = length ; } List < Coordinate > coordinatesList = new ArrayList < Coordinate > ( ) ; LengthIndexedLine indexedLine = new LengthIndexedLine ( line ) ; Coordinate [ ] existingCoordinates = null ; double [ ] indexOfExisting = null ; if ( keepExisting ) { existingCoordinates = line . getCoordinates ( ) ; indexOfExisting = new double [ existingCoordinates . length ] ; int i = 0 ; for ( Coordinate coordinate : existingCoordinates ) { double indexOf = indexedLine . indexOf ( coordinate ) ; indexOfExisting [ i ] = indexOf ; i ++ ; } } double runningLength = startFrom ; int currentIndexOfexisting = 1 ; // jump first while ( runningLength < endAt ) { if ( keepExisting && currentIndexOfexisting < indexOfExisting . length - 1 && runningLength > indexOfExisting [ currentIndexOfexisting ] ) { // add the existing coordinatesList . add ( existingCoordinates [ currentIndexOfexisting ] ) ; currentIndexOfexisting ++ ; continue ; } Coordinate extractedPoint = indexedLine . extractPoint ( runningLength ) ; coordinatesList . add ( extractedPoint ) ; runningLength = runningLength + interval ; } Coordinate extractedPoint = indexedLine . extractPoint ( endAt ) ; coordinatesList . add ( extractedPoint ) ; return coordinatesList ; } | Returns the coordinates at a given interval along the line . | 394 | 11 |
16,978 | 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 ; } if ( endAt < 0 ) { endAt = length ; } double halfWidth = width / 2.0 ; List < LineString > linesList = new ArrayList < LineString > ( ) ; LengthIndexedLine indexedLine = new LengthIndexedLine ( line ) ; double runningLength = startFrom ; while ( runningLength < endAt ) { Coordinate centerCoordinate = indexedLine . extractPoint ( runningLength ) ; Coordinate leftCoordinate = indexedLine . extractPoint ( runningLength , - halfWidth ) ; Coordinate rightCoordinate = indexedLine . extractPoint ( runningLength , halfWidth ) ; LineString lineString = geomFactory . createLineString ( new Coordinate [ ] { leftCoordinate , centerCoordinate , rightCoordinate } ) ; linesList . add ( lineString ) ; runningLength = runningLength + interval ; } Coordinate centerCoordinate = indexedLine . extractPoint ( endAt ) ; Coordinate leftCoordinate = indexedLine . extractPoint ( endAt , - halfWidth ) ; Coordinate rightCoordinate = indexedLine . extractPoint ( endAt , halfWidth ) ; LineString lineString = geomFactory . createLineString ( new Coordinate [ ] { leftCoordinate , centerCoordinate , rightCoordinate } ) ; linesList . add ( lineString ) ; return linesList ; } | Returns the section line at a given interval along the line . | 368 | 12 |
16,979 | 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 scaleHeight = 0 ; scaleWidth = toAdaptWidth / origWidth ; scaleHeight = toAdaptHeight / origHeight ; double scaleFactor ; if ( doShrink ) { scaleFactor = Math . min ( scaleWidth , scaleHeight ) ; } else { scaleFactor = Math . max ( scaleWidth , scaleHeight ) ; } double newWidth = origWidth * scaleFactor ; double newHeight = origHeight * scaleFactor ; double dw = ( toAdaptWidth - newWidth ) / 2.0 ; double dh = ( toAdaptHeight - newHeight ) / 2.0 ; double newX = toScale . getX ( ) + dw ; double newY = toScale . getY ( ) + dh ; double newW = toAdaptWidth - 2 * dw ; double newH = toAdaptHeight - 2 * dh ; toScale . setRect ( newX , newY , newW , newH ) ; } | Extends or shrinks a rectangle following the ration of a fixed one . | 276 | 15 |
16,980 | 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 factor = toScaleWidth / fitWidth ; toScaleWidth = fitWidth ; toScaleHeight = toScaleHeight / factor ; } if ( toScaleHeight > fitHeight ) { double factor = toScaleHeight / fitHeight ; toScaleHeight = fitHeight ; toScaleWidth = toScaleWidth / factor ; } toScale . setRect ( 0 , 0 , toScaleWidth , toScaleHeight ) ; } | Scales a rectangle down to fit inside the given one keeping the ratio . | 175 | 15 |
16,981 | 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 - lC2 . z ) ; if ( denominator == 0.0 ) { return null ; } double u = ( p [ 0 ] * lC1 . x + p [ 1 ] * lC1 . y + p [ 2 ] * lC1 . z + p [ 3 ] ) / // denominator ; double x = lC1 . x + ( lC2 . x - lC1 . x ) * u ; double y = lC1 . y + ( lC2 . y - lC1 . y ) * u ; double z = lC1 . z + ( lC2 . z - lC1 . z ) * u ; return new Coordinate ( x , y , z ) ; } | Get the intersection coordinate between a line and plane . | 282 | 10 |
16,982 | 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 } ; double [ ] n = { // /* */ rDB [ 1 ] * rDC [ 2 ] - rDC [ 1 ] * rDB [ 2 ] , // - 1 * ( rDB [ 0 ] * rDC [ 2 ] - rDC [ 0 ] * rDB [ 2 ] ) , // rDB [ 0 ] * rDC [ 1 ] - rDC [ 0 ] * rDB [ 1 ] // } ; double cosNum = n [ 0 ] * rAD [ 0 ] + n [ 1 ] * rAD [ 1 ] + n [ 2 ] * rAD [ 2 ] ; double cosDen = sqrt ( n [ 0 ] * n [ 0 ] + n [ 1 ] * n [ 1 ] + n [ 2 ] * n [ 2 ] ) * sqrt ( rAD [ 0 ] * rAD [ 0 ] + rAD [ 1 ] * rAD [ 1 ] + rAD [ 2 ] * rAD [ 2 ] ) ; double cos90MinAlpha = abs ( cosNum / cosDen ) ; double alpha = 90.0 - toDegrees ( acos ( cos90MinAlpha ) ) ; return alpha ; } | Calculates the angle between line and plane . | 370 | 10 |
16,983 | 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 . | 57 | 24 |
16,984 | 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 ( angleInTriangle ) ; return degrees ; } | Calculates the angle in degrees between 3 3D coordinates . | 110 | 13 |
16,985 | @ 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 > merged = lineMerger . getMergedLineStrings ( ) ; List < LineString > mergedList = new ArrayList <> ( ) ; for ( Geometry geom : merged ) { mergedList . add ( ( LineString ) geom ) ; } return mergedList ; } | Tries to merge multilines when they are snapped properly . | 157 | 13 |
16,986 | 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 instanceof LineString ) { LineString line = ( LineString ) geometryN ; polygons . addAll ( makeArrows ( line ) ) ; } else if ( geometryN instanceof Polygon ) { Polygon polygonGeom = ( Polygon ) geometryN ; LineString exteriorRing = polygonGeom . getExteriorRing ( ) ; polygons . addAll ( makeArrows ( exteriorRing ) ) ; int numInteriorRing = polygonGeom . getNumInteriorRing ( ) ; for ( int j = 0 ; j < numInteriorRing ; j ++ ) { LineString interiorRingN = polygonGeom . getInteriorRingN ( j ) ; polygons . addAll ( makeArrows ( interiorRingN ) ) ; } } } } return polygons ; } | Creates simple arrow polygons in the direction of the coordinates . | 262 | 13 |
16,987 | public boolean overlaps ( Location location ) { if ( location . getBeginPosition ( ) >= getBeginPosition ( ) && location . getBeginPosition ( ) <= getEndPosition ( ) ) return true ; if ( location . getBeginPosition ( ) <= getBeginPosition ( ) && location . getEndPosition ( ) >= getBeginPosition ( ) ) return true ; else { return false ; } } | 6361 .. 6539 6363 .. 6649 | 82 | 10 |
16,988 | 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 . | 75 | 14 |
16,989 | private double degreeToNumber ( String value ) { double number = - 1 ; String [ ] valueSplit = value . trim ( ) . split ( ":" ) ; //$NON-NLS-1$ if ( valueSplit . length == 3 ) { // deg:min:sec.ss double deg = Double . parseDouble ( valueSplit [ 0 ] ) ; double min = Double . parseDouble ( valueSplit [ 1 ] ) ; double sec = Double . parseDouble ( valueSplit [ 2 ] ) ; number = deg + min / 60.0 + sec / 60.0 / 60.0 ; } else if ( valueSplit . length == 2 ) { // deg:min double deg = Double . parseDouble ( valueSplit [ 0 ] ) ; double min = Double . parseDouble ( valueSplit [ 1 ] ) ; number = deg + min / 60.0 ; } else if ( valueSplit . length == 1 ) { // deg number = Double . parseDouble ( valueSplit [ 0 ] ) ; } return number ; } | Transforms degree string into the decimal value . | 216 | 9 |
16,990 | 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 ) ; } else { yres = Double . parseDouble ( nsres ) ; } return new double [ ] { xres , yres } ; } | Transforms a GRASS resolution string in metric or degree to decimal . | 142 | 14 |
16,991 | @ 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 , north . length ( ) - 1 ) ; no = degreeToNumber ( north ) ; } else if ( north . indexOf ( "S" ) != - 1 || north . indexOf ( "s" ) != - 1 ) { north = north . substring ( 0 , north . length ( ) - 1 ) ; no = - degreeToNumber ( north ) ; } else { no = Double . parseDouble ( north ) ; } if ( south . indexOf ( "N" ) != - 1 || south . indexOf ( "n" ) != - 1 ) { south = south . substring ( 0 , south . length ( ) - 1 ) ; so = degreeToNumber ( south ) ; } else if ( south . indexOf ( "S" ) != - 1 || south . indexOf ( "s" ) != - 1 ) { south = south . substring ( 0 , south . length ( ) - 1 ) ; so = - degreeToNumber ( south ) ; } else { so = Double . parseDouble ( south ) ; } if ( west . indexOf ( "E" ) != - 1 || west . indexOf ( "e" ) != - 1 ) { west = west . substring ( 0 , west . length ( ) - 1 ) ; we = degreeToNumber ( west ) ; } else if ( west . indexOf ( "W" ) != - 1 || west . indexOf ( "w" ) != - 1 ) { west = west . substring ( 0 , west . length ( ) - 1 ) ; we = - degreeToNumber ( west ) ; } else { we = Double . parseDouble ( west ) ; } if ( east . indexOf ( "E" ) != - 1 || east . indexOf ( "e" ) != - 1 ) { east = east . substring ( 0 , east . length ( ) - 1 ) ; ea = degreeToNumber ( east ) ; } else if ( east . indexOf ( "W" ) != - 1 || east . indexOf ( "w" ) != - 1 ) { east = east . substring ( 0 , east . length ( ) - 1 ) ; ea = - degreeToNumber ( east ) ; } else { ea = Double . parseDouble ( east ) ; } return new double [ ] { no , so , ea , we } ; } | Transforms the GRASS bounds strings in metric or degree to decimal . | 606 | 14 |
16,992 | @ Override public int read ( ) throws IOException { // initalize the lookahead if ( lookaheadChar == UNDEFINED ) { lookaheadChar = super . read ( ) ; } lastChar = lookaheadChar ; if ( super . ready ( ) ) { lookaheadChar = super . read ( ) ; } else { lookaheadChar = UNDEFINED ; } if ( lastChar == ' ' ) { lineCounter ++ ; } return lastChar ; } | Reads the next char from the input stream . | 100 | 10 |
16,993 | public int read ( char [ ] buf , int off , int len ) throws IOException { // do not claim if len == 0 if ( len == 0 ) { return 0 ; } // init lookahead, but do not block !! if ( lookaheadChar == UNDEFINED ) { if ( ready ( ) ) { lookaheadChar = super . read ( ) ; } else { return - 1 ; } } // 'first read of underlying stream' if ( lookaheadChar == - 1 ) { return - 1 ; } // continue until the lookaheadChar would block int cOff = off ; while ( len > 0 && ready ( ) ) { if ( lookaheadChar == - 1 ) { // eof stream reached, do not continue return cOff - off ; } else { buf [ cOff ++ ] = ( char ) lookaheadChar ; if ( lookaheadChar == ' ' ) { lineCounter ++ ; } lastChar = lookaheadChar ; lookaheadChar = super . read ( ) ; len -- ; } } return cOff - off ; } | Non - blocking reading of len chars into buffer buf starting at bufferposition off . | 221 | 16 |
16,994 | public long skip ( long n ) throws IllegalArgumentException , IOException { if ( lookaheadChar == UNDEFINED ) { lookaheadChar = super . read ( ) ; } // illegal argument if ( n < 0 ) { throw new IllegalArgumentException ( "negative argument not supported" ) ; } // no skipping if ( n == 0 || lookaheadChar == END_OF_STREAM ) { return 0 ; } // skip and reread the lookahead-char long skiped = 0 ; if ( n > 1 ) { skiped = super . skip ( n - 1 ) ; } lookaheadChar = super . read ( ) ; // fixme uh: we should check the skiped sequence for line-terminations... lineCounter = Integer . MIN_VALUE ; return skiped + 1 ; } | Skips char in the stream | 169 | 6 |
16,995 | 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 . | 80 | 15 |
16,996 | private int [ ] [ ] createStationBasinsMatrix ( double [ ] statValues , int [ ] activeStationsPerBasin ) { int [ ] [ ] stationsBasins = new int [ stationCoordinates . size ( ) ] [ basinBaricenterCoordinates . size ( ) ] ; Set < Integer > bandsIdSet = bin2StationsListMap . keySet ( ) ; Integer [ ] bandsIdArray = ( Integer [ ] ) bandsIdSet . toArray ( new Integer [ bandsIdSet . size ( ) ] ) ; // for every basin for ( int i = 0 ; i < basinBaricenterCoordinates . size ( ) ; i ++ ) { Coordinate basinBaricenterCoordinate = basinBaricenterCoordinates . get ( i ) ; // for every stations band int activeStationsForThisBasin = 0 ; for ( int j = 0 ; j < bandsIdArray . length ; j ++ ) { int bandId = bandsIdArray [ j ] ; List < Integer > stationIdsForBand = bin2StationsListMap . get ( bandId ) ; /* * search for the nearest stations that have values. */ List < Integer > stationsToUse = extractStationsToUse ( basinBaricenterCoordinate , stationIdsForBand , stationId2CoordinateMap , statValues , stationid2StationindexMap ) ; if ( stationsToUse . size ( ) < pNum ) { pm . message ( "Found only " + stationsToUse . size ( ) + " for basin " + basinindex2basinidMap . get ( i ) + " and bandid " + bandId + "." ) ; } /* * now we have the list of stations to use. With this list we * need to enable (1) the proper matrix positions inside the * stations-basins matrix. */ // i is the column (basin) index // the station id index can be taken from the idStationIndexMap // System.out.print("STATIONS for basin " + basinindex2basinidMap.get(i) + ": "); for ( Integer stationIdToEnable : stationsToUse ) { int stIndex = stationid2StationindexMap . get ( stationIdToEnable ) ; stationsBasins [ stIndex ] [ i ] = 1 ; // System.out.print(stationIdToEnable + ", "); } // System.out.println(); activeStationsForThisBasin = activeStationsForThisBasin + stationsToUse . size ( ) ; } activeStationsPerBasin [ i ] = activeStationsForThisBasin ; } return stationsBasins ; } | Creates the stations per basins matrix . | 565 | 9 |
16,997 | 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 ( ) ; i ++ ) { pm . worked ( 1 ) ; SimpleFeature stationF = stationFeatures . get ( i ) ; Coordinate stationCoord = stationCoordinates . get ( i ) ; if ( stationIdIndex == - 1 ) { SimpleFeatureType featureType = stationF . getFeatureType ( ) ; stationIdIndex = featureType . indexOf ( fStationid ) ; stationElevIndex = featureType . indexOf ( fStationelev ) ; if ( stationIdIndex == - 1 ) { throw new IllegalArgumentException ( "Could not find the field: " + fStationid ) ; } if ( stationElevIndex == - 1 ) { throw new IllegalArgumentException ( "Could not find the field: " + fStationelev ) ; } } int id = ( ( Number ) stationF . getAttribute ( stationIdIndex ) ) . intValue ( ) ; double elev = ( ( Number ) stationF . getAttribute ( stationElevIndex ) ) . doubleValue ( ) ; statElev [ i ] = elev ; statId [ i ] = id ; stationId2CoordinateMap . put ( id , stationCoord ) ; } pm . done ( ) ; // sort QuickSortAlgorithm qsA = new QuickSortAlgorithm ( pm ) ; qsA . sort ( statElev , statId ) ; } | Fills the elevation and id arrays for the stations ordering in ascending elevation order . | 368 | 16 |
16,998 | 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 | 78 | 9 |
16,999 | 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 | 46 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.