⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circleraster.java

📁 geotools的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package uk.ac.leeds.ccg.raster;

import java.lang.*;
import java.io.*;
//import java.util.*;
import com.sun.java.util.collections.*; //change for 1.2!
import uk.ac.leeds.ccg.geotools.*;

public final class circleRaster extends Raster{

	private final static boolean DEBUG=true;
	private boolean quantizeOn = true;
    public boolean isQuantizeOn(){
        return quantizeOn;
    }
    public void setQuantizeOn(boolean flag){
        quantizeOn=flag;
    }

	/**
	 * Builds a raster surface based on an array of circles,
	 * produces the
	 * surface by using a density kernel based on the value of the circle.
	 * The mapextent is calculated from the circles.
	 * @see uk.ac.leeds.ccg.raster.circleRaster#quantize
	 * @param circles[] the array of circles
	 * @param size the size of the cells in the raster
	 * @param data[] the values of the circles
	 */
	public circleRaster(){
		super();
		if(DEBUG)System.out.println("---->uk.ac.leeds.ccg.raster.circleRaster constructed. Will identify itself as CRa->");
	}
	public circleRaster(GeoCircle[] circles,double size,double data[]){
		if(DEBUG)System.out.println("---->uk.ac.leeds.ccg.raster.circleRaster constructed. Will identify itself as CRa->");
		sparseness=0.0d;
		sparse=true;
		GeoRectangle extent = new GeoRectangle();
		cellsize=size; // we should calculate this?
		for(int i=0; i<circles.length;i++)
			extent.add(circles[i].getBounds());
		originx=extent.x;
		originx=Math.floor(extent.x/cellsize)*cellsize;
		originy=extent.y;
		originy=Math.floor(extent.y/cellsize)*cellsize;
		width=(int)Math.ceil(extent.width/cellsize);
		height=(int)Math.ceil(extent.height/cellsize);
		cells= new double[height*width];
		for(int i=0; i<circles.length;i++){
			if(onSurface(circles[i].getX(),circles[i].getY())){
				quantize(circles[i].getX(),circles[i].getY(),circles[i].getRadius(),
					data[i]);
			}
		}
		if(getSparseness()>50.0d) {
			setSparse(true);
		}
		min=Double.MAX_VALUE;
		max=Double.MIN_VALUE;
		for(int i=0;i<(height);i++){
			for(int j=0;j<width;j++){
				min=Math.min(min,getCell(i,j));
				max=Math.max(max,getCell(i,j));
			}
		}
	}
	public circleRaster(Vector circles,double size,double data[]){
		sparseness=0.0d;
		sparse=true;
		GeoRectangle extent = new GeoRectangle();
		cellsize=size; // we should calculate this?
		for(int i=0; i<circles.size();i++)
			extent.add(((GeoCircle)circles.elementAt(i)).getBounds());
		originx=extent.x;
		originx=Math.floor(extent.x/cellsize)*cellsize;
		originy=extent.y;
		originy=Math.floor(extent.y/cellsize)*cellsize;
		width=(int)Math.ceil(extent.width/cellsize);
		height=(int)Math.ceil(extent.height/cellsize);
		cells= new double[height*width];
		GeoCircle c;
		for(int i=0; i<circles.size();i++){
			c=(GeoCircle)circles.elementAt(i);
			if(onSurface(c.getX(),c.getY())){
				quantize(c.getX(),c.getY(),c.getRadius(),
					data[i]);
			}
		}
		if(getSparseness()>50.0d) {
			setSparse(true);
		}
		min=Double.MAX_VALUE;
		max=Double.MIN_VALUE;
		for(int i=0;i<(height);i++){
			for(int j=0;j<width;j++){
				min=Math.min(min,getCell(i,j));
				max=Math.max(max,getCell(i,j));
			}
		}
	}
	public circleRaster(Vector circles,double size,GeoData data){
		sparseness=0.0d;
		sparse=true;
		GeoRectangle extent = new GeoRectangle();
		cellsize=size; // we should calculate this?
		for(int i=0; i<circles.size();i++)
			extent.add(((GeoCircle)circles.elementAt(i)).getBounds());
		originx=extent.x;
		originx=Math.floor(extent.x/cellsize)*cellsize;
		originy=extent.y;
		originy=Math.floor(extent.y/cellsize)*cellsize;
		width=(int)Math.ceil(extent.width/cellsize);
		height=(int)Math.ceil(extent.height/cellsize);
		cells= new double[height*width];
		GeoCircle c;
		for(int i=0; i<circles.size();i++){
			c=(GeoCircle)circles.elementAt(i);
			if(onSurface(c.getX(),c.getY())){
				quantize(c.getX(),c.getY(),c.getRadius(),
					data.getValue(c.getID()));
			}
		}
		if(getSparseness()>50.0d) {
			setSparse(true);
		}
		min=Double.MAX_VALUE;
		max=Double.MIN_VALUE;
		for(int i=0;i<(height);i++){
			for(int j=0;j<width;j++){
				min=Math.min(min,getCell(i,j));
				max=Math.max(max,getCell(i,j));
			}
		}
	}
	/**
   * Builds a raster surface based on an array of circles,
   * produces the
   * surface by using a density kernel based on the value of the circle.
   * @see uk.ac.leeds.ccg.raster.circleRaster#quantize
   * @param circles[] the array of circles
   * @param size the size of the cells in the raster
   * @param data[] the values of the circles
	 * @param m the mapextent of the raster.
   */

	public circleRaster(GeoCircle[] circles,double size,double data[],GeoRectangle
			m ){
	    this(circles,size,data,m,true);
	        }
	public circleRaster(Vector circles,double size,double data[],GeoRectangle
			m ){
	    this(circles,size,data,m,true);
		}
	public circleRaster(GeoCircle[] circles,double size,double data[],GeoRectangle
			m ,boolean quantize){
		if(DEBUG)System.out.println("---->uk.ac.leeds.ccg.raster.circleRaster constructed. Will identify itself as CRa->");
		setQuantizeOn(quantize);
		sparseness=0.0d;
		GeoRectangle extent = m;
		cellsize=size; // we should calculate this?
		originx=extent.x;
		originx=Math.floor(extent.x/cellsize)*cellsize;
		originy=extent.y;
		originy=Math.floor(extent.y/cellsize)*cellsize;
		width=(int)Math.ceil(extent.width/cellsize);
		height=(int)Math.ceil(extent.height/cellsize);
		cells= new double[height*width];
		for(int i=0; i<circles.length;i++){
			if(onSurface(circles[i].getX(),circles[i].getY())){
				quantize(circles[i].getX(),circles[i].getY(),circles[i].getRadius(),
					data[i]);
			}
		}
		if(getSparseness()>50.0d) {
			setSparse(true);
		}
		min=Double.MAX_VALUE;
		max=Double.MIN_VALUE;
		for(int i=0;i<height;i++){
			for(int j=0;j<width;j++){
				min=Math.min(min,getCell(i,j));
				max=Math.max(max,getCell(i,j));
			}
		}
	}
	public circleRaster(Vector circles,double size,double data[],GeoRectangle
			m ,boolean quantize){
	    setQuantizeOn(quantize);     
		sparseness=0.0d;
		GeoRectangle extent = m;
		cellsize=size; // we should calculate this?
		originx=extent.x;
		originx=Math.floor(extent.x/cellsize)*cellsize;
		originy=extent.y;
		originy=Math.floor(extent.y/cellsize)*cellsize;
		width=(int)Math.ceil(extent.width/cellsize);
		height=(int)Math.ceil(extent.height/cellsize);
		cells= new double[height*width];
		GeoCircle c;
		for(int i=0; i<circles.size();i++){
		 c = (GeoCircle)circles.elementAt(i);
			if(onSurface(c.getX(),c.getY())){
				quantize(c.getX(),c.getY(),c.getRadius(),
					data[i]);
			}
		}
		if(getSparseness()>50.0d) {
			setSparse(true);
		}
		min=Double.MAX_VALUE;
		max=Double.MIN_VALUE;
		for(int i=0;i<height;i++){
			for(int j=0;j<width;j++){
				min=Math.min(min,getCell(i,j));
				max=Math.max(max,getCell(i,j));
			}
		}
	}
	
	
	
	/**
   * Builds an empty raster surface based
   * @see uk.ac.leeds.ccg.raster.circleRaster#quantize
   * @param size the size of the cells in the raster
   * @param m the mapextent of the raster.
   */

	public circleRaster(double size,GeoRectangle m ){
		if(DEBUG)System.out.println("---->uk.ac.leeds.ccg.raster.circleRaster constructed. Will identify itself as CRa->");
		sparseness=0.0d;
		GeoRectangle extent = m;
		cellsize=size; // we should calculate this?
		originx=extent.x;
		originx=Math.floor(extent.x/cellsize)*cellsize;
		originy=extent.y;
		originy=Math.floor(extent.y/cellsize)*cellsize;
		width=(int)Math.ceil(extent.width/cellsize);
		height=(int)Math.ceil(extent.height/cellsize);
		cells= new double[height*width];

		if(getSparseness()>50.0d) {
			setSparse(true);
		}
		min=Double.MAX_VALUE;
		max=Double.MIN_VALUE;

	}


	/**
	 * Builds a raster surface of the centres of the circles

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -