• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.geojson;
2 
3 import java.io.Serializable;
4 import java.util.Arrays;
5 
6 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
7 import com.fasterxml.jackson.annotation.JsonInclude;
8 import com.fasterxml.jackson.annotation.JsonInclude.Include;
9 import com.fasterxml.jackson.annotation.JsonSubTypes;
10 import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
11 import com.fasterxml.jackson.annotation.JsonTypeInfo;
12 import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
13 
14 @JsonTypeInfo(property = "type", use = Id.NAME)
15 @JsonSubTypes({ @Type(Feature.class), @Type(Polygon.class), @Type(MultiPolygon.class), @Type(FeatureCollection.class),
16 		@Type(Point.class), @Type(MultiPoint.class), @Type(MultiLineString.class), @Type(LineString.class),
17                 @Type(GeometryCollection.class) })
18 @JsonInclude(Include.NON_NULL)
19 @JsonIgnoreProperties(ignoreUnknown = true)
20 public abstract class GeoJsonObject implements Serializable {
21 
22 	private Crs crs;
23 	private double[] bbox;
getCrs()24 	public Crs getCrs() {
25 		return crs;
26 	}
27 
setCrs(Crs crs)28 	public void setCrs(Crs crs) {
29 		this.crs = crs;
30 	}
31 
getBbox()32 	public double[] getBbox() {
33 		return bbox;
34 	}
35 
setBbox(double[] bbox)36 	public void setBbox(double[] bbox) {
37 		this.bbox = bbox;
38 	}
39 
accept(GeoJsonObjectVisitor<T> geoJsonObjectVisitor)40 	public abstract <T> T accept(GeoJsonObjectVisitor<T> geoJsonObjectVisitor);
41 
equals(Object o)42 	@Override public boolean equals(Object o) {
43 		if (this == o)
44 			return true;
45 		if (o == null || getClass() != o.getClass())
46 			return false;
47 		GeoJsonObject that = (GeoJsonObject)o;
48 		if (crs != null ? !crs.equals(that.crs) : that.crs != null)
49 			return false;
50 		return Arrays.equals(bbox, that.bbox);
51 	}
52 
hashCode()53 	@Override public int hashCode() {
54 		int result = crs != null ? crs.hashCode() : 0;
55 		result = 31 * result + (bbox != null ? Arrays.hashCode(bbox) : 0);
56 		return result;
57 	}
58 
59 	@Override
toString()60 	public String toString() {
61 		return "GeoJsonObject{}";
62 	}
63 }
64