| /** |
| * FILE: testGeoJS.java |
| * PATH: org.datasyslab.geospark.utils.testGeoJS.java |
| * Copyright (c) 2016 Arizona State University Data Systems Lab. |
| * All rights reserved. |
| */ |
| package org.datasyslab.geospark.utils; |
| |
| import org.apache.log4j.Level; |
| import org.apache.log4j.Logger; |
| import org.apache.spark.SparkConf; |
| import org.apache.spark.api.java.JavaSparkContext; |
| import org.junit.AfterClass; |
| import org.junit.BeforeClass; |
| import org.junit.Test; |
| import org.wololo.geojson.GeoJSON; |
| import org.wololo.jts2geojson.GeoJSONWriter; |
| |
| /** |
| * |
| * @author Arizona State University DataSystems Lab |
| * |
| */ |
| |
| import com.vividsolutions.jts.geom.Coordinate; |
| import com.vividsolutions.jts.geom.Geometry; |
| import com.vividsolutions.jts.geom.GeometryFactory; |
| |
| // TODO: Auto-generated Javadoc |
| /** |
| * The Class testGeoJS. |
| */ |
| public class testGeoJS { |
| |
| /** The sc. */ |
| public static JavaSparkContext sc; |
| |
| /** |
| * Once executed before all. |
| */ |
| @BeforeClass |
| public static void onceExecutedBeforeAll() { |
| SparkConf conf = new SparkConf().setAppName("JobTileMatchWithAcronymExpension").setMaster("local[2]"); |
| sc = new JavaSparkContext(conf); |
| Logger.getLogger("org").setLevel(Level.WARN); |
| Logger.getLogger("akka").setLevel(Level.WARN); |
| } |
| |
| /** |
| * Jts 2 geonjs. |
| */ |
| @Test |
| public void jts2geonjs(){ |
| GeometryFactory geometryFactory = new GeometryFactory(); |
| Coordinate coordinate = new Coordinate(1.0, 2.0); |
| Geometry point = geometryFactory.createPoint(coordinate); |
| |
| GeoJSONWriter writer = new GeoJSONWriter(); |
| GeoJSON json = writer.write(point); |
| String jsonstring = json.toString(); |
| |
| System.out.println(jsonstring); |
| } |
| |
| /** |
| * Tear down. |
| */ |
| @AfterClass |
| public static void TearDown() { |
| sc.stop(); |
| } |
| } |