@Test public void testParse() throws Exception { What3WordsSearchChannel channel = new What3WordsSearchChannel(); JSONObject json = ResourceHelper.readJSONResource("What3Words-success.json", this); SearchResultItem item = channel.parseResult(json, "EPSG:3067"); assertEquals("Title", item.getTitle(), "carting.pint.invent"); assertEquals("Lat", item.getLat(), 6675293.715526561, 0.1); assertEquals("Lon", item.getLon(), 385547.65760422836, 0.1); }
public SearchResultItem parseResult(JSONObject dataItem, String targetSrs) throws Exception { final CoordinateReferenceSystem sourceCrs = CRS.decode(SERVICE_SRS); final CoordinateReferenceSystem targetCrs = CRS.decode(targetSrs); final SearchResultItem item = new SearchResultItem(); item.setType("what3words"); String title = dataItem.optString("words"); item.setTitle(title); item.setDescription(title); final JSONObject position = JSONHelper.getJSONObject(dataItem, "geometry"); final double lat = position.optDouble("lat"); final double lon = position.optDouble("lng"); final Point point = ProjectionHelper.transformPoint(lon, lat, sourceCrs, targetCrs); if(point == null) { return null; } item.setLon(point.getLon()); item.setLat(point.getLat()); return item; }
What3WordsSearchChannel extends SearchChannel { public SearchResultItem parseResult(JSONObject dataItem, String targetSrs) throws Exception { final CoordinateReferenceSystem sourceCrs = CRS.decode(SERVICE_SRS); final CoordinateReferenceSystem targetCrs = CRS.decode(targetSrs); final SearchResultItem item = new SearchResultItem(); item.setType("what3words"); String title = dataItem.optString("words"); item.setTitle(title); item.setDescription(title); final JSONObject position = JSONHelper.getJSONObject(dataItem, "geometry"); final double lat = position.optDouble("lat"); final double lon = position.optDouble("lng"); final Point point = ProjectionHelper.transformPoint(lon, lat, sourceCrs, targetCrs); if(point == null) { return null; } item.setLon(point.getLon()); item.setLat(point.getLat()); return item; } }
What3WordsSearchChannel extends SearchChannel { public SearchResultItem parseResult(JSONObject dataItem, String targetSrs) throws Exception { final CoordinateReferenceSystem sourceCrs = CRS.decode(SERVICE_SRS); final CoordinateReferenceSystem targetCrs = CRS.decode(targetSrs); final SearchResultItem item = new SearchResultItem(); item.setType("what3words"); String title = dataItem.optString("words"); item.setTitle(title); item.setDescription(title); final JSONObject position = JSONHelper.getJSONObject(dataItem, "geometry"); final double lat = position.optDouble("lat"); final double lon = position.optDouble("lng"); final Point point = ProjectionHelper.transformPoint(lon, lat, sourceCrs, targetCrs); if(point == null) { return null; } item.setLon(point.getLon()); item.setLat(point.getLat()); return item; }  }
What3WordsSearchChannel extends SearchChannel { public SearchResultItem parseResult(JSONObject dataItem, String targetSrs) throws Exception { final CoordinateReferenceSystem sourceCrs = CRS.decode(SERVICE_SRS); final CoordinateReferenceSystem targetCrs = CRS.decode(targetSrs); final SearchResultItem item = new SearchResultItem(); item.setType("what3words"); String title = dataItem.optString("words"); item.setTitle(title); item.setDescription(title); final JSONObject position = JSONHelper.getJSONObject(dataItem, "geometry"); final double lat = position.optDouble("lat"); final double lon = position.optDouble("lng"); final Point point = ProjectionHelper.transformPoint(lon, lat, sourceCrs, targetCrs); if(point == null) { return null; } item.setLon(point.getLon()); item.setLat(point.getLat()); return item; }  @Override void init(); boolean isValidSearchTerm(SearchCriteria criteria); Capabilities getCapabilities(); ChannelSearchResult doSearch(SearchCriteria searchCriteria); Point getServiceCoordinates(double lon, double lat, String srs); ChannelSearchResult reverseGeocode(SearchCriteria sc); SearchResultItem parseResult(JSONObject dataItem, String targetSrs); int getRank(String type); }
What3WordsSearchChannel extends SearchChannel { public SearchResultItem parseResult(JSONObject dataItem, String targetSrs) throws Exception { final CoordinateReferenceSystem sourceCrs = CRS.decode(SERVICE_SRS); final CoordinateReferenceSystem targetCrs = CRS.decode(targetSrs); final SearchResultItem item = new SearchResultItem(); item.setType("what3words"); String title = dataItem.optString("words"); item.setTitle(title); item.setDescription(title); final JSONObject position = JSONHelper.getJSONObject(dataItem, "geometry"); final double lat = position.optDouble("lat"); final double lon = position.optDouble("lng"); final Point point = ProjectionHelper.transformPoint(lon, lat, sourceCrs, targetCrs); if(point == null) { return null; } item.setLon(point.getLon()); item.setLat(point.getLat()); return item; }  @Override void init(); boolean isValidSearchTerm(SearchCriteria criteria); Capabilities getCapabilities(); ChannelSearchResult doSearch(SearchCriteria searchCriteria); Point getServiceCoordinates(double lon, double lat, String srs); ChannelSearchResult reverseGeocode(SearchCriteria sc); SearchResultItem parseResult(JSONObject dataItem, String targetSrs); int getRank(String type); static final String ID; static final String SERVICE_SRS; }