org.datasyslab.geosparkviz.extension.visualizationEffect.HeatMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geospark-viz Show documentation
Show all versions of geospark-viz Show documentation
Geospatial visualization extension of GeoSpark
/**
* FILE: HeatMap.java
* PATH: org.datasyslab.geosparkviz.extension.visualizationEffect.HeatMap.java
* Copyright (c) 2015-2017 GeoSpark Development Team
* All rights reserved.
*/
package org.datasyslab.geosparkviz.extension.visualizationEffect;
import java.awt.Color;
import org.apache.log4j.Logger;
import org.apache.spark.api.java.JavaSparkContext;
import org.datasyslab.geosparkviz.core.VisualizationOperator;
import org.datasyslab.geosparkviz.extension.photoFilter.GaussianBlur;
import org.datasyslab.geosparkviz.utils.ColorizeOption;
import org.datasyslab.geospark.spatialRDD.SpatialRDD;
import com.vividsolutions.jts.geom.Envelope;
// TODO: Auto-generated Javadoc
/**
* The Class HeatMap.
*/
public class HeatMap extends VisualizationOperator{
/** The Constant logger. */
final static Logger logger = Logger.getLogger(HeatMap.class);
/**
* Instantiates a new heat map.
*
* @param resolutionX the resolution X
* @param resolutionY the resolution Y
* @param datasetBoundary the dataset boundary
* @param reverseSpatialCoordinate the reverse spatial coordinate
* @param blurRadius the blur radius
*/
public HeatMap(int resolutionX, int resolutionY, Envelope datasetBoundary, boolean reverseSpatialCoordinate,int blurRadius)
{
super(resolutionX, resolutionY, datasetBoundary, ColorizeOption.SPATIALAGGREGATION, reverseSpatialCoordinate,-1,-1,false,false,false);
GaussianBlur gaussianBlur = new GaussianBlur(blurRadius);
this.InitPhotoFilterWeightMatrix(gaussianBlur);
}
/**
* Instantiates a new heat map.
*
* @param resolutionX the resolution X
* @param resolutionY the resolution Y
* @param datasetBoundary the dataset boundary
* @param reverseSpatialCoordinate the reverse spatial coordinate
* @param blurRadius the blur radius
* @param partitionX the partition X
* @param partitionY the partition Y
* @param parallelPhotoFilter the parallel photo filter
* @param parallelRenderImage the parallel render image
*/
public HeatMap(int resolutionX, int resolutionY, Envelope datasetBoundary, boolean reverseSpatialCoordinate,int blurRadius,
int partitionX, int partitionY, boolean parallelPhotoFilter, boolean parallelRenderImage)
{
super(resolutionX, resolutionY, datasetBoundary, ColorizeOption.SPATIALAGGREGATION, reverseSpatialCoordinate,
partitionX, partitionY, parallelPhotoFilter, parallelRenderImage,false);
GaussianBlur gaussianBlur = new GaussianBlur(blurRadius);
this.InitPhotoFilterWeightMatrix(gaussianBlur);
}
/* (non-Javadoc)
* @see org.datasyslab.geosparkviz.core.VisualizationOperator#EncodeToColor(int)
*/
@Override
protected Integer EncodeToRGB(int normailizedCount) throws Exception
{
int alpha = 150;
Color[] colors = new Color[]{new Color(153,255,0,alpha),new Color(204,255,0,alpha),new Color(255,255,0,alpha),
new Color(255,204,0,alpha),new Color(255,153,0,alpha),new Color(255,102,0,alpha),
new Color(255,51,0,alpha),new Color(255,0,0,alpha)};
if (normailizedCount < 1){
return new Color(255,255,255,0).getRGB();
}
else if(normailizedCount<30)
{
return colors[0].getRGB();
}
else if(normailizedCount<50)
{
return colors[1].getRGB();
}
else if(normailizedCount<70)
{
return colors[2].getRGB();
}
else if(normailizedCount<100)
{
return colors[3].getRGB();
}
else if(normailizedCount<130)
{
return colors[4].getRGB();
}
else if(normailizedCount<160)
{
return colors[5].getRGB();
}
else if(normailizedCount<190)
{
return colors[6].getRGB();
}
else
{
return colors[7].getRGB();
}
}
/**
* Visualize.
*
* @param sparkContext the spark context
* @param spatialRDD the spatial RDD
* @return true, if successful
* @throws Exception the exception
*/
public boolean Visualize(JavaSparkContext sparkContext, SpatialRDD spatialRDD) throws Exception {
logger.info("[GeoSparkViz][Visualize][Start]");
this.CustomizeColor(255, 255, 0, 255, Color.GREEN, true);
this.Rasterize(sparkContext, spatialRDD, true);
this.ApplyPhotoFilter(sparkContext);
this.Colorize();
this.RenderImage(sparkContext);
logger.info("[GeoSparkViz][Visualize][Stop]");
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy