Skip to content

Instantly share code, notes, and snippets.

View mraad's full-sized avatar

Mansour mraad

View GitHub Profile
@mraad
mraad / main.js
Created December 26, 2012 13:01
Main.js
$(document).ready(function () {
'use strict';
var mapServerInfo;
document.getElementById('buttonLocate').addEventListener('click', function (e) {
e.preventDefault();
var level = $('#inputLevel').val(),
row = $('#inputRow').val(),
col = $('#inputCol').val();
console.log(level, row, col);
/*
@mraad
mraad / kdmap.java
Last active December 14, 2015 11:28
Kernel Density Map Function
@Override
protected void map(
final LongWritable key,
final Text value,
final Context context) throws IOException, InterruptedException
{
final String[] tokens = value.toString().split("\t");
if (tokens.length != 4)
{
return;
@mraad
mraad / kdreduce.java
Last active December 14, 2015 11:28
Kernel Density Reduce Function
@Override
protected void reduce(
final Text key,
final Iterable<DoubleWritable> values,
final Context context) throws IOException, InterruptedException
{
double sum = 0.0;
for (final DoubleWritable doubleWritable : values)
{
sum += doubleWritable.get();
@mraad
mraad / application-context.xml
Last active December 14, 2015 11:29
Kernel Density Spring Configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
<hdp:configuration id="hadoopConfiguration">
fs.defaultFS=hdfs://10.12.51.70:8020
@mraad
mraad / application-context-cdh4.xml
Created March 4, 2013 22:14
Spring application context for CDH4
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
<hdp:configuration id="hadoopConfiguration">
fs.defaultFS=hdfs://10.12.51.70:8020
@mraad
mraad / application-context-cdh4.xml
Created March 27, 2013 12:50
Spring job declaration
<hdp:job id="mr-job"
jar-by-class="com.esri.density.Main"
input-path="/user/mraad_admin/infousa"
output-path="/user/mraad_admin/raster"
mapper="com.esri.density.CellFilterMapper"
combiner="com.esri.density.CellReducer"
reducer="com.esri.density.CellReducer"/>
@mraad
mraad / AppDistance.java
Created April 2, 2013 10:30
AppDistance - DataRush graph using DistanceOperator
public final class AppDistance
{
public static void main(String[] args)
{
final boolean local = args.length == 0;
final LogicalGraph graph = LogicalGraphFactory.newLogicalGraph("AppDistance");
final TextRecord schema = SchemaBuilder.define(
SchemaBuilder.DOUBLE("LON"),
@mraad
mraad / App.java
Created April 3, 2013 02:40
Execute exported KNIME workflow
public class App
{
public static void main(String[] args) throws IOException
{
if (args.length != 4)
{
System.err.println("Usage: " + App.class + " workflow.dr workflow.properties num-parallelism local|dr://dr-host:1099");
return;
}
@mraad
mraad / model.py
Last active December 15, 2015 18:20
Python model to excute DataRushTool and display raster outputin ArcMap
# -*- coding: utf-8 -*-
import arcpy
arcpy.ImportToolbox("C:/mraad/DataRushToolbox.tbx")
arcpy.gp.toolbox = "C:/mraad/DataRushToolbox.tbx";
arcpy.gp.DataRushTool("C:/tmp/workflow.dr", "C:/tmp/workflow.properties", "local", "0")
density = "C:/tmp/density2"
arcpy.FloatToRaster_conversion("C:/tmp/raster.flt", density)
@RequestMapping(value = "/rest/services/InfoUSA/MapServer", method = RequestMethod.GET)
public void doMapServer(
final HttpServletResponse response
) throws IOException
{
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("application/json");
response.setContentLength(m_byteArrayOutputStream.size());
m_byteArrayOutputStream.writeTo(response.getOutputStream());
response.getOutputStream().flush();