Java Code Examples for com.thinkaurelius.titan.core.attribute.Geoshape#GeoshapeSerializer
The following examples show how to use
com.thinkaurelius.titan.core.attribute.Geoshape#GeoshapeSerializer .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@Test public void testGeoJsonCircle() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Circle\",\n" + " \"radius\": 30.5, " + " \"coordinates\": [20.5, 10.5]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); assertEquals(Geoshape.circle(10.5, 20.5, 30.5), s.convert(json)); }
Example 2
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void testGeoJsonPolygonNotBox1() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Polygon\",\n" + " \"coordinates\": [[20.5, 12.5],[22.5, 12.5],[22.5, 10.5],[20.5, 10.6]]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); s.convert(json); }
Example 3
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void testGeoJsonPolygonNotBox2() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Polygon\",\n" + " \"coordinates\": [[20.5, 10.5],[22.5, 10.5],[22.5, 12.5]]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); s.convert(json); }
Example 4
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testParseCollection() { Geoshape.GeoshapeSerializer serializer = new Geoshape.GeoshapeSerializer(); assertEquals(Geoshape.point(10, 20), serializer.convert(Arrays.asList(10, 20))); assertEquals(Geoshape.circle(10, 20, 30), serializer.convert(Arrays.asList(10, 20, 30))); assertEquals(Geoshape.box(10, 20, 30, 40), serializer.convert(Arrays.asList(10, 20, 30, 40))); }
Example 5
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testGeoJsonPoint() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Point\",\n" + " \"coordinates\": [20.5, 10.5]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); assertEquals(Geoshape.point(10.5, 20.5), s.convert(json)); }
Example 6
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testGeoJsonPointUnparseable() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Point\",\n" + " \"coordinates\": [20.5, \"10.5\"]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); s.convert(json); }
Example 7
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testGeoJsonCircleMissingRadius() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Circle\",\n" + " \"coordinates\": [20.5, 10.5]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); s.convert(json); }
Example 8
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testGeoJsonPolygon() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Polygon\",\n" + " \"coordinates\": [[20.5, 10.5],[22.5, 10.5],[22.5, 12.5],[20.5, 12.5]]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); assertEquals(Geoshape.box(10.5, 20.5, 12.5, 22.5), s.convert(json)); //Try the reverse order points json = new ObjectMapper().readValue("{\n" + " \"type\": \"Feature\",\n" + " \"geometry\": {\n" + " \"type\": \"Polygon\",\n" + " \"coordinates\": [[20.5, 12.5],[22.5, 12.5],[22.5, 10.5],[20.5, 10.5]]\n" + " },\n" + " \"properties\": {\n" + " \"name\": \"Dinagat Islands\"\n" + " }\n" + "}", HashMap.class); assertEquals(Geoshape.box(10.5, 20.5, 12.5, 22.5), s.convert(json)); }
Example 9
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testGeoJsonGeometry() throws IOException { Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer(); Map json = new ObjectMapper().readValue("{\n" + " \"type\": \"Point\",\n" + " \"coordinates\": [20.5, 10.5]\n" + "}", HashMap.class); assertEquals(Geoshape.point(10.5, 20.5), s.convert(json)); }
Example 10
Source File: GeoshapeTest.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testFailParseCollection() { Geoshape.GeoshapeSerializer serializer = new Geoshape.GeoshapeSerializer(); serializer.convert(Arrays.asList(10, "Foo")); }