Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
 package com.sitewhere.geospatial;
 
Utility functions for dealing with geographic information.

Author(s):
Derek
public class GeoUtils {

Creates a JTS point from a device location.

Parameters:
location
Returns:
	public static Point createPointForLocation(IDeviceLocation location) {
		return fact.createPoint(new Coordinate(location.getLongitude(), location.getLatitude()));
	}

Creates a JTS polygon based on zone definition.

Parameters:
zone
Returns:
	public static Polygon createPolygonForZone(IZone zone) {
	}

Create a polgon for a list of locations.

Parameters:
locations
Returns:
	public static <T extends ILocationPolygon createPolygonForLocations(List<T> locations) {
		Coordinate[] coords = new Coordinate[locations.size() + 1];
		for (int x = 0; x < locations.size(); x++) {
			ILocation loc = locations.get(x);
			coords[x] = new Coordinate(loc.getLongitude(), loc.getLatitude());
		}
		ILocation loc = locations.get(0);
		coords[locations.size()] = new Coordinate(loc.getLongitude(), loc.getLatitude());
		LinearRing linear = new GeometryFactory().createLinearRing(coords);
		return new Polygon(linearnullfact);
	}
New to GrepCode? Check out our FAQ X