/** * {@inheritDoc} */ public Object addYToPoint(double y, Object point) { ((JSONArray) ((LinkedHashMap) point).get("coordinates")).set(1, y); return point; }
/** * {@inheritDoc} */ public Object addXToPoint(double x, Object point) { ((JSONArray) ((LinkedHashMap) point).get("coordinates")).set(0, x); return point; }
/** * Data to be set on specified index of items on a ModelObject of type Array. * * @param index position at which the item is to be set * @param data data to be set */ @SuppressWarnings("unchecked") public void setDataAtItemsIndex(int index, JSONObject data) { if (modelType == ModelPropertyType.ARRAY) { objectItems.set(index, data); } else { Exception exception = new SchemaTypeException(ModelPropertyType.ARRAY); logger.log(Level.SEVERE, "An exception was thrown", exception); } }
/** * {@inheritDoc} */ public Object endPoint(Object point, String from, String to) { JSONArray coords = ((JSONArray) ((LinkedHashMap) point) .get("coordinates")); try { double[] xy = GeotoolsUtils.transform( from, to, new double[] { Double.valueOf(String.valueOf(coords.get(0))), Double.valueOf(String.valueOf(coords.get(1))) }); if (xy != null) { coords.set(0, xy[0]); coords.set(1, xy[1]); ((LinkedHashMap) point).put("coordinates", coords); } } catch (Exception e) { e.printStackTrace(); } return point; }
parentJsonText.jsonArray.set(index, newKeyValue);