code
stringlengths
73
34.1k
label
stringclasses
1 value
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); ...
java
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; }
java
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); }
java
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....
java
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); } L...
java
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(); ...
java
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 (s...
java
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; ...
java
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 > fit...
java
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...
java
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 = {// ...
java
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; }
java
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(an...
java
@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); } ...
java
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); ...
java
public boolean overlaps(Location location) { if (location.getBeginPosition()>=getBeginPosition() && location.getBeginPosition() <= getEndPosition()) return true; if(location.getBeginPosition() <= getBeginPosition() && location.getEndPosition()>=getBeginPosition()) return tr...
java
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; }
java
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(va...
java
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) {...
java
@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 = n...
java
@Override public int read() throws IOException { // initalize the lookahead if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } lastChar = lookaheadChar; if (super.ready()) { lookaheadChar = super.read(); } else { look...
java
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()...
java
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"); } /...
java
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(); }
java
private int[][] createStationBasinsMatrix( double[] statValues, int[] activeStationsPerBasin ) { int[][] stationsBasins = new int[stationCoordinates.size()][basinBaricenterCoordinates.size()]; Set<Integer> bandsIdSet = bin2StationsListMap.keySet(); Integer[] bandsIdArray = (Integer[]) bandsIdSet...
java
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...
java
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}; }
java
public int[] PixelsToRaster( int px, int py, int zoom ) { int mapSize = tileSize << zoom; return new int[]{px, mapSize - py}; }
java
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; // We don't want to scale up } } ...
java
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); }
java
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; } ...
java
private void net( WritableRandomIter hacksIter, WritableRandomIter netIter ) { // calculates the max order of basin (max hackstream value) pm.beginTask("Extraction of rivers of chosen order...", nRows); for( int r = 0; r < nRows; r++ ) { for( int c = 0; c < nCols; c++ ) { ...
java
public static ByteBuffer bytes(String s, Charset charset) { return ByteBuffer.wrap(s.getBytes(charset)); }
java
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, GFF3Gene>(); ...
java
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 != '...
java
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...
java
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; } ...
java
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' ) { ...
java
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 : ...
java
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; }
java
public static String shrink(String string) { if (string == null) { return null; } string = string.trim(); return SHRINK.matcher(string).replaceAll(" "); }
java
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)); }
java
public static String remove(String string, char c) { return string.replaceAll(String.valueOf(c), ""); }
java
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; }
java
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; // d_w and d_h are assumed to be set to the y = (i / d_w) + oy; // width and height of scr1d if ((x < 0) || (x >= d_w) || (y < 0) || (y >= d_h)) { resul...
java
private int reduce( int a, int[] labels ) { if (labels[a] == a) { return a; } else { return reduce(labels[a], labels); } }
java
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; }
java
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); }
java
public static boolean inRange(Range range, double val) { return val >= range.min() && val <= range.max(); }
java
public void close() { entry.close(); getBlockCounter().clear(); getSkipTagCounter().clear(); getCache().resetOrganismCache(); getCache().resetReferenceCache(); }
java
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[]...
java
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 = activ...
java
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(); do...
java
public static boolean removeGrassRasterMap( String mapsetPath, String mapName ) throws IOException { // list of files to remove String mappaths[] = filesOfRasterMap(mapsetPath, mapName); // first delete the list above, which are just files for( int j = 0; j < mappaths.length; j++ ) { ...
java
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]; ...
java
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 = Mat...
java
public void deleteGeoTable( String tableName ) throws Exception { String sql = "SELECT DropGeoTable('" + tableName + "');"; try (IHMStatement stmt = mConn.createStatement()) { stmt.execute(sql); } }
java
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(...
java
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...
java
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)...
java
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 && !adding...
java
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(); ...
java
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(); ...
java
public void addDwgSectionOffset( String key, int seek, int size ) { DwgSectionOffset dso = new DwgSectionOffset(key, seek, size); dwgSectionOffsets.add(dso); }
java
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.ge...
java
public void addDwgObjectOffset( int handle, int offset ) { DwgObjectOffset doo = new DwgObjectOffset(handle, offset); dwgObjectOffsets.add(doo); }
java
protected void initValidator() throws SQLException, IOException { EmblEntryValidationPlanProperty emblEntryValidationPlanProperty = new EmblEntryValidationPlanProperty(); emblEntryValidationPlanProperty.validationScope.set(ValidationScope.getScope(fileType)); emblEntryValidationPlanProperty.isDevMode.set(testMo...
java
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.tx...
java
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 BufferedReader(new F...
java
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: re...
java
private void writeResultsToFile(ValidationPlanResult planResult) throws IOException { /** * first set any report messages (probably exceptional that the * translation report needs to get set outside the embl-api-core package * due to the need for embl-ff writers **/ for (ValidationResult result : plan...
java
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"); // writer fixes automatically if quotes are not gi...
java
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; ...
java
public void verifyNet( Pipe[] networkPipes, IHMProgressMonitor pm ) { /* * serve per verificare che ci sia almeno un'uscita. True= esiste * un'uscita */ boolean isOut = false; if (networkPipes != null) { /* VERIFICA DATI GEOMETRICI DELLA RETE */ ...
java
public boolean joinLine() { if (!isCurrentLine()) { return false; } if (!isNextLine()) { return false; } if (!isNextTag()) { return true; // no next tag -> continue block } if (!isCurrentTag()) { return false; // no current tag -> new block } // compare current and next tag return getCur...
java
public String getCurrentLine() { if (!isCurrentLine()) { return null; } if (isTag(currentLine)) return FlatFileUtils.trimRight(currentLine, getTagWidth(currentLine)); else return currentLine.trim(); }
java
public String getNextLine() { if (!isNextLine()) { return null; } if (isTag(nextLine)) return FlatFileUtils.trimRight(nextLine, getTagWidth(nextLine)); else return nextLine.trim(); }
java
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.substring(tagWidth)...
java
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(tagWidth)); } return...
java
public String getCurrentShrinkedLine() { if (!isCurrentLine()) { return null; } String string = FlatFileUtils.trim(currentLine, getTagWidth(currentLine)); if (string.equals("")) { return null; } return FlatFileUtils.shrink(string); }
java
public void propertyChange( PropertyChangeEvent evt ) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressMonitor.setProgress(progress); // String message = String.format("Completed %d%%.\n", progress); // progressMonit...
java
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}; } ...
java
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; } r...
java
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."); } ...
java
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 g...
java
public void write( String path ) throws Exception { if (makeNew) { RasterWriter.writeRaster(path, buildRaster()); } else { throw new RuntimeException("Only new rasters can be dumped."); } }
java
public static Raster read( String path ) throws Exception { GridCoverage2D coverage2d = RasterReader.readRaster(path); Raster raster = new Raster(coverage2d); return raster; }
java
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 Temp...
java
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 : grou...
java
public void shrink() { if (c.length == length) { return; } char[] newc = new char[length]; System.arraycopy(c, 0, newc, 0, length); c = newc; }
java
public StringBuffer toStringBuffer() { StringBuffer sb = new StringBuffer(length); sb.append(c, 0, length); return sb; }
java
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value, WritableRaster[] writableRasterHolder ) { RegionMap regionMap = getRegionParamsFromGridCoverage(template); double xRes = regionMap.getXres(); double yRes = regionM...
java
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[]{widt...
java
public static int[] getLoopColsRowsForSubregion( GridCoverage2D gridCoverage, Envelope2D subregion ) throws Exception { GridGeometry2D gridGeometry = gridCoverage.getGridGeometry(); GridEnvelope2D subRegionGrid = gridGeometry.worldToGrid(subregion); int minCol = subRegionGrid.x; int maxC...
java
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); ...
java
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, nu...
java
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); } ...
java
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 = r...
java
public static ROI prepareROI( Geometry roi, AffineTransform mt2d ) throws Exception { // transform the geometry to raster space so that we can use it as a ROI source Geometry rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse())); // simplify the geometry so that ...
java
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") && w...
java