@Override public Object getInstance(Class<?> clazz) { return new Point(0.0, 0.0); }
@Override public Point getCopy(Object object) { if (object == null) return null; Point p = (Point) object; return new Point(p.getX(), p.getY()); }
@Override public Point fromString(Class targetClass, String s) { if (s == null) return null; WKTReader reader = new WKTReader(); try { return new Point((com.vividsolutions.jts.geom.Point) reader.read(s)); } catch (ParseException e) { log.error("Parse exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
public List<Person> findNear(double x, double y, double maxDistance, SurfaceType surfaceType) { Point point = new Point(x, y); point.setSurfaceType(surfaceType); Query q = em .createQuery("Select p from Person p where p.currentLocation > :point AND p.currentLocation < :maxDistance"); q.setParameter("point", point); q.setParameter("maxDistance", maxDistance); List<Person> persons = q.getResultList(); return persons; }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#getCopy(java.lang.Object)} * . */ @Test public void testGetCopy() { Point point = new Point(4.5, 6.3); Point point2 = pa.getCopy(point); Assert.assertFalse(point == point2); Assert.assertTrue(point.equals(point2)); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#toBytes(java.lang.Object)} * . */ @Test public void testToBytes() { Point point = new Point(4.5, 6.3); byte[] input = pa.toBytes(point); Point point2 = pa.fromBytes(Point.class, input); Assert.assertTrue(point.equals(point2)); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#fromBytes(java.lang.Class, byte[])} * . */ @Test public void testFromBytes() { Point point = new Point(4.5, 6.3); byte[] input = pa.toBytes(point); Point point2 = pa.fromBytes(Point.class, input); Assert.assertTrue(point.equals(point2)); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#toString(java.lang.Object)} * . */ @Test public void testToStringObject() { Point point = new Point(4.5, 6.3); String pointStr = pa.toString(point); WKTWriter writer = new WKTWriter(); String wktStr = writer.write(point); Assert.assertEquals(wktStr, pointStr); }
private void addPersons() { dao.createEntityManager(); for (int i = 0; i < 100; i++) { double x = i % 10; double y = Math.floor(i / 10); Person person = new Person(); person.setPersonId(i + 1); person.setName("Amresh_" + (i + 1)); person.setCurrentLocation(new Point(x, y)); Vehicle vehicle = new Vehicle(); vehicle.setCurrentLocation(new Point(x + 1.0, y + 1.0)); vehicle.setPreviousLocation(new Point(x + 2.0, y + 2.0)); person.setVehicle(vehicle); dao.addPerson(person); } dao.closeEntityManager(); }
@Test public void test() { Coordinate coordiates2d = new Coordinate(34.2d,34.4d); Coordinate[] coordinates = new Coordinate[1]; coordinates[0]=coordiates2d; com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float floatSequence = new com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float(coordinates, 2); GeometryFactory geoFactory = new GeometryFactory(new PrecisionModel(2)); Point point = new Point(floatSequence,geoFactory); point.setSRID(2); point.setSurfaceType(SurfaceType.FLAT); Geometry geometry = new com.vividsolutions.jts.geom.Point(floatSequence,geoFactory); Assert.assertTrue(point.contains(geometry)); Assert.assertTrue(point.getSurfaceType() != null); Assert.assertEquals(SurfaceType.FLAT,point.getSurfaceType()); Assert.assertEquals(2,point.getSRID()); point = new Point(coordiates2d,new PrecisionModel(2),12); Assert.assertNotNull(point); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#fromString(java.lang.Class, java.lang.String)} * . */ @Test public void testFromString() { Point point = new Point(4.5, 6.3); WKTWriter writer = new WKTWriter(); String wktStr = writer.write(point); Point point2 = pa.fromString(com.vividsolutions.jts.geom.Point.class, wktStr); Assert.assertNotNull(point2); Assert.assertEquals(point.getX(), point2.getX()); Assert.assertEquals(point.getY(), point2.getY()); }
double y = Double.parseDouble(yObj.toString()); Point point = new Point(x, y); PropertyAccessorHelper.set(entityObject, (Field) column.getJavaMember(), point);
double y = Double.parseDouble(yObj.toString()); Point point = new Point(x, y); PropertyAccessorHelper.set(entityObject, (Field) column.getJavaMember(), point);