-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
486 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
build/ | ||
output/ | ||
dot/ | ||
.gradle/ | ||
|
||
*~ | ||
*.class | ||
.DS_Store | ||
|
||
# Package Files # | ||
*.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2007-2012 Concurrent, Inc. All Rights Reserved. | ||
* | ||
* Project and contact information: http://www.cascading.org/ | ||
* | ||
* This file is part of the Cascading project. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package copa; | ||
|
||
import cascading.flow.FlowProcess; | ||
import cascading.operation.BaseOperation; | ||
import cascading.operation.Function; | ||
import cascading.operation.FunctionCall; | ||
import cascading.tuple.Fields; | ||
import cascading.tuple.Tuple; | ||
import cascading.tuple.TupleEntry; | ||
|
||
|
||
public class AlbedoFunction extends BaseOperation implements Function | ||
{ | ||
protected Integer year_new = 0; | ||
|
||
public AlbedoFunction( Fields fieldDeclaration, Integer year_new ) | ||
{ | ||
super( 1, fieldDeclaration ); | ||
this.year_new = year_new; | ||
} | ||
|
||
public void operate( FlowProcess flowProcess, FunctionCall functionCall ) | ||
{ | ||
TupleEntry argument = functionCall.getArguments(); | ||
Integer year_construct = argument.getInteger( 0 ); | ||
Double albedo_new = argument.getDouble( 1 ); | ||
Double albedo_worn = argument.getDouble( 2 ); | ||
|
||
Double albedo = ( year_construct >= year_new ) ? albedo_new : albedo_worn; | ||
|
||
Tuple result = new Tuple(); | ||
result.add( albedo ); | ||
functionCall.getOutputCollector().add( result ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2007-2012 Concurrent, Inc. All Rights Reserved. | ||
* | ||
* Project and contact information: http://www.cascading.org/ | ||
* | ||
* This file is part of the Cascading project. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package copa; | ||
|
||
import org.apache.lucene.spatial.geohash.GeoHashUtils; | ||
|
||
import cascading.flow.FlowProcess; | ||
import cascading.operation.BaseOperation; | ||
import cascading.operation.Function; | ||
import cascading.operation.FunctionCall; | ||
import cascading.tuple.Fields; | ||
import cascading.tuple.Tuple; | ||
import cascading.tuple.TupleEntry; | ||
|
||
|
||
public class GeoHashFunction extends BaseOperation implements Function | ||
{ | ||
public GeoHashFunction( Fields fieldDeclaration ) | ||
{ | ||
super( 1, fieldDeclaration ); | ||
} | ||
|
||
public void operate( FlowProcess flowProcess, FunctionCall functionCall ) | ||
{ | ||
TupleEntry argument = functionCall.getArguments(); | ||
Double lat = argument.getDouble( 0 ); | ||
Double lng = argument.getDouble( 1 ); | ||
|
||
GeoHashUtils ghu = new GeoHashUtils(); | ||
String geohash = ghu.encode( lat, lng ); | ||
|
||
Tuple result = new Tuple(); | ||
result.add( geohash.substring( 0, 5 ) ); | ||
functionCall.getOutputCollector().add( result ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2007-2012 Concurrent, Inc. All Rights Reserved. | ||
* | ||
* Project and contact information: http://www.cascading.org/ | ||
* | ||
* This file is part of the Cascading project. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package copa; | ||
|
||
import cascading.flow.FlowProcess; | ||
import cascading.operation.BaseOperation; | ||
import cascading.operation.Function; | ||
import cascading.operation.FunctionCall; | ||
import cascading.tuple.Fields; | ||
import cascading.tuple.Tuple; | ||
import cascading.tuple.TupleEntry; | ||
|
||
|
||
public class RoadSegmentFunction extends BaseOperation implements Function | ||
{ | ||
public RoadSegmentFunction( Fields fieldDeclaration ) | ||
{ | ||
super( 1, fieldDeclaration ); | ||
} | ||
|
||
public void operate( FlowProcess flowProcess, FunctionCall functionCall ) | ||
{ | ||
TupleEntry argument = functionCall.getArguments(); | ||
String[] geo_list = argument.getString( 0 ).split( "\\s" ); | ||
|
||
for( int i = 0; i < ( geo_list.length - 1 ); i++ ) | ||
{ | ||
String[] p0 = geo_list[i].split( "," ); | ||
Double lng0 = new Double( p0[0] ); | ||
Double lat0 = new Double( p0[1] ); | ||
Double alt0 = new Double( p0[2] ); | ||
|
||
String[] p1 = geo_list[i + 1].split( "," ); | ||
Double lng1 = new Double( p1[0] ); | ||
Double lat1 = new Double( p1[1] ); | ||
Double alt1 = new Double( p1[2] ); | ||
|
||
Double lat_mid = ( lat0 + lat1 ) / 2.0; | ||
Double lng_mid = ( lng0 + lng1 ) / 2.0; | ||
|
||
Double slope = ( lat1 - lat0 ) / ( lng1 - lng0 ); | ||
Double intercept = lat0 - ( slope * lng0 ); | ||
|
||
Tuple result = new Tuple(); | ||
|
||
result.add( lat0 ); | ||
result.add( lng0 ); | ||
result.add( alt0 ); | ||
|
||
result.add( lat1 ); | ||
result.add( lng1 ); | ||
result.add( alt1 ); | ||
|
||
result.add( lat_mid ); | ||
result.add( lng_mid ); | ||
|
||
result.add( slope ); | ||
result.add( intercept ); | ||
|
||
functionCall.getOutputCollector().add( result ); | ||
} | ||
} | ||
} |
Oops, something went wrong.