static PointPropertyType TopointPropertyType(double x, double y, double z) { PointPropertyType ppt = PointPropertyType.Factory.newInstance(); PointType pnt = ppt.addNewPoint(); DirectPositionType pos = pnt.addNewPos(); pos.setStringValue(posListString(x, y, z)); return ppt; }
public AnnotationResponseDocument completeResponse(WHSServiceVO vo) { LOG.debug("X1: " + vo.getTransformedCoordinateX()); LOG.debug("Y1: " + vo.getTransformedCoordinateY()); LOG.debug("Z1: " + vo.getTransformedCoordinateZ()); String x1 = vo.getTransformedCoordinateX(); String x2 = String.valueOf( Double.parseDouble(vo.getTransformedCoordinateX()) + Double.parseDouble(vo.getTolerance())); String x3 = String.valueOf( Double.parseDouble(vo.getTransformedCoordinateX()) + Double.parseDouble(vo.getTolerance())); String x4 = vo.getTransformedCoordinateX(); String y1 = vo.getTransformedCoordinateY(); String y2 = vo.getTransformedCoordinateY(); String y3 = String.valueOf( Double.parseDouble(vo.getTransformedCoordinateY()) - Double.parseDouble(vo.getTolerance())); String y4 = String.valueOf( Double.parseDouble(vo.getTransformedCoordinateY()) - Double.parseDouble(vo.getTolerance())); AnnotationResponseDocument doc = AnnotationResponseDocument.Factory.newInstance(); AnnotationResponse annResp = doc.addNewAnnotationResponse(); String polygonString = x1 + " " + y1 + "," + x2 + " " + y2 + "," + x3 + " " + y3 + "," + x4 + " " + y4 + "," + x1 + " " + y1; LOG.debug("Artibrary polygon string - {}", polygonString); ArrayList annotationDataList = new ArrayList(); WHSServiceDAOImpl daoImpl = new WHSServiceDAOImpl(); LOG.debug("*********************************SRSName outside: " + vo.getFromSRSCode()); LOG.debug("*********************************filter outside: " + vo.getFilter()); if (!vo.getFromSRSCode().equalsIgnoreCase("image")) { LOG.debug("*********************************SRSName inside Image: " + vo.getSrsName()); annotationDataList = daoImpl.getAnnotationData(vo, polygonString); } else if (vo.getFromSRSCode().equalsIgnoreCase("image")) { LOG.debug( "*********************************SRSName inside Not Actual SRSName: " + vo.getFromSRSCode()); annotationDataList = daoImpl.getAnnotationData(vo); } else { // FIXME - Put some exception code here to throw an exception LOG.debug("SRS TYPE NOT SUPPORTED"); } Iterator iterator0 = annotationDataList.iterator(); String id = ""; String path = ""; HashMap map = new HashMap(); while (iterator0.hasNext()) { vo = (WHSServiceVO) iterator0.next(); id = vo.getUniqueID(); path = vo.getOntoFilePath(); map.put(id, path); } LOG.debug("Map Size: " + map.size()); Iterator annotationsIterator = map.keySet().iterator(); String key = ""; while (annotationsIterator.hasNext()) { key = annotationsIterator.next().toString(); LOG.debug("*****************New Annotation*****************"); AnnotationType ann = annResp.addNewAnnotation(); Iterator dataIterator = annotationDataList.iterator(); GEOMETRYTYPE geom1 = null; AnnPolygonType polygon1 = null; GEOMETRIES geometries = null; geometries = ann.addNewGEOMETRIES(); geom1 = geometries.addNewGEOMETRY(); // Resource and Geometries should be only one time RESOURCE res = ann.addNewRESOURCE(); /* CentralServiceVO vo1 = null; while (dataIterator.hasNext()) { vo1 = (CentralServiceVO)dataIterator.next(); LOG.debug("**Key from Hash Map:**" + key ); LOG.debug("**Key from Collection:**" + vo1.getUniqueID() ); if (key.equals(vo1.getUniqueID())){ */ LOG.debug("*****************New Data Inside Annotation*****************"); // Loop here - New Annotation Iterator iterator1 = annotationDataList.iterator(); WHSServiceVO vo2 = null; // Delete this loop while (iterator1.hasNext()) { vo2 = (WHSServiceVO) iterator1.next(); LOG.debug("##Original Key MAP INSIDEPOLYGON:##" + key); LOG.debug("##Key from Collection INSIDE POLYGON:##" + vo2.getUniqueID()); if (vo2.getUniqueID().equals(key)) { polygon1 = geom1.addNewPOLYGON(); LOG.debug("##Inside POLYGON:##"); /* LOG.debug("Date is: " + date ); LOG.debug("Time is: " + date.getTime() ); LOG.debug("Day is: " + date.getDate() ); */ // FIXME - update the unique url below from the db res.setFilepath(vo2.getOntoFilePath()); geom1.setUserName(vo2.getUserName()); if (vo2.getSrsName() == null || vo2.getSrsName().equals("")) { polygon1.setSrsName("Undefined"); } else { polygon1.setSrsName(vo2.getSrsName()); } polygon1.setId(gmlId(vo2.getPolygonID())); // date = vo.getUpdatedTime(); // FIXME Calendar cal = Calendar.getInstance(); cal.setTime(vo.getUpdatedTime()); ann.setMODIFIEDDATE(cal); // FIXME - modifiedTime // long modifiedTime = Long.parseLong(vo1.getUpdatedTime()); Date date = null; // FIXME geom1.setModifiedTime(vo.getUpdatedTime().getTime()); AbstractRingPropertyType poly1exterior = polygon1.addNewExterior(); XmlObject ring = poly1exterior.addNewAbstractRing(); XmlObject linearRing = ring.substitute( new QName("http://www.opengis.net/gml/3.2", "LinearRing"), LinearRingType.type); DirectPositionType pos1 = ((LinearRingType) linearRing).addNewPos(); pos1.setStringValue(vo2.getTransformedCoordinates().replaceAll(",", " ")); } } GENERALONTOMODEL model1 = ann.addNewGENERALONTOMODEL(); RELATIONSTYPE relations = model1.addNewRELATIONS(); Iterator iterator2 = annotationDataList.iterator(); WHSServiceVO vo3 = null; while (iterator2.hasNext()) { vo3 = (WHSServiceVO) iterator2.next(); if (vo3.getUniqueID().equals(key)) { ONTOPROPERTYTYPE prop2 = relations.addNewONTOPROPERTY(); prop2.setTitle("has_geometry"); // Below URL never changes prop2.setHref( "http://ontology.neuinfo.org/NIF/Backend/NIFSTD_Datatype_properties.owl#hasGeometry"); prop2.setUserName(vo3.getUserName()); // FIXME - modifiedTime prop2.setModifiedTime(vo.getUpdatedTime().getTime()); SUBJECTTYPE subj2 = prop2.addNewSUBJECT(); ONTOTERMTYPE term2_1 = subj2.addNewONTOTERM(); term2_1.setTitle(vo3.getOntoName()); term2_1.setHref(vo3.getOntoURI()); term2_1.setId(gmlId(vo3.getPolygonID())); // term2_1.newCursor().insertComment(" title = onto_name, href = onto_url gml:id= // instance_id"); OBJECTTYPE obj2 = prop2.addNewOBJECT(); GEOMETRYTYPE term2_2 = obj2.addNewGEOMETRY(); term2_2.setHref(gmlIdInteralReference(gmlId(vo3.getPolygonID()))); } } ONTOTERMS terms = ann.addNewONTOTERMS(); Iterator iterator3 = annotationDataList.iterator(); WHSServiceVO vo4 = null; while (iterator3.hasNext()) { vo4 = (WHSServiceVO) iterator3.next(); if (vo4.getUniqueID().equals(key)) { ONTOTERMTYPE term2 = terms.addNewONTOTERM(); term2.setId(gmlId(vo4.getPolygonID())); term2.setHref(vo4.getOntoURI()); term2.setTitle(vo4.getOntoName()); } } // } // } } return doc; }