/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(InstanceComponent instance, Object value) throws Exception { Envelope e = new Envelope(); e.setToNull(); return e; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Envelope envelope = (Envelope) node.getChildValue(Envelope.class); if (envelope == null) { envelope = new Envelope(); envelope.setToNull(); } return envelope; }
/** * Returns the envelope for a geometry. * * <p>This method will return an "null" envelope ({@link Envelope#setToNull()}) if <tt>wkb</tt> * is <code>null</code>. * * @param wkb The geometry. * @return The envelope of the geometry. */ public static Envelope Envelope(byte[] wkb) { if (wkb == null) { Envelope e = new Envelope(); e.setToNull(); return e; } return fromWKB(wkb).getEnvelopeInternal(); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { // do the null check if (node.getChild("null") != null) { // ignore the description as to why its null Envelope e = new Envelope(); e.setToNull(); return e; } // has to be a valid bounding box return (Envelope) node.getChildValue(0); }
public void testEncodeAsNull() throws Exception { Envelope e = new Envelope(); e.setToNull(); Document dom = encode(e, GML.boundedBy); assertEquals("gml:Null", dom.getDocumentElement().getFirstChild().getNodeName()); } }
public void testEncodeAsNull() throws Exception { Envelope e = new Envelope(); e.setToNull(); Document dom = encode(e, GML.boundedBy); assertEquals("gml:Null", dom.getDocumentElement().getFirstChild().getNodeName()); } }
public void testEncodeNull() throws Exception { Envelope e = new Envelope(); e.setToNull(); Document dom = encode(e, GML.Envelope); assertEquals( 1, dom.getElementsByTagNameNS(GML.NAMESPACE, GML.Null.getLocalPart()).getLength()); } }
/** * Initialize to a null <code>Envelope</code>. */ public void init() { setToNull(); }
/** * Expands this envelope by a given distance in all directions. * Both positive and negative distances are supported. * * @param deltaX the distance to expand the envelope along the the X axis * @param deltaY the distance to expand the envelope along the the Y axis */ public void expandBy(double deltaX, double deltaY) { if (isNull()) return; minx -= deltaX; maxx += deltaX; miny -= deltaY; maxy += deltaY; // check for envelope disappearing if (minx > maxx || miny > maxy) setToNull(); }
protected void writeBBox(Writer w, Node node, Envelope envHelper) throws IOException { envHelper.setToNull(); node.expand(envHelper); writeEnvelope(w, envHelper); }
public int writeBucket(@NonNull FlatBufferBuilder builder, @NonNull Bucket bucket, @NonNull Envelope envBuff) { envBuff.setToNull(); bucket.expand(envBuff); return writeBucket(builder, bucket.getIndex(), bucket.getObjectId(), envBuff); }
public static void writeBucket(int index, Bucket bucket, DataOutput data, Envelope envBuff) { try { data.writeInt(index); bucket.getObjectId().writeTo(data); envBuff.setToNull(); bucket.expand(envBuff); writeBoundingBox(envBuff, data); } catch (IOException e) { throw new RuntimeException(e); } }
/** * @return a 3-elements boolean array where the first one indicates if at least one node has * bounds, the seconds if it has extradata map, and the third if it has a metadataId */ private boolean[] hasBoundsOrExtraData(List<Node> nodes, Envelope buff) { boolean hasBounds = false; boolean hasExtraData = false; boolean hasMetadataId = false; final int size = nodes.size(); for (int i = 0; i < size; i++) { buff.setToNull(); Node node = nodes.get(i); node.expand(buff); if (!buff.isNull()) { hasBounds = true; } Map<String, Object> extraData = node.getExtraData(); if (!extraData.isEmpty()) { hasExtraData = true; } if (node.getMetadataId().isPresent()) { hasMetadataId = true; } if (hasBounds && hasExtraData && hasMetadataId) { return new boolean[] { true, true, true }; } } return new boolean[] { hasBounds, hasExtraData, hasMetadataId }; }
public static void writeNode(Node node, DataOutput data, Envelope envBuff) { try { data.writeUTF(node.getName()); node.getObjectId().writeTo(data); node.getMetadataId().or(ObjectId.NULL).writeTo(data); int typeN = node.getType().value(); data.writeByte(typeN); envBuff.setToNull(); node.expand(envBuff); writeBoundingBox(envBuff, data); Map<String, Object> extraData = node.getExtraData(); DataStreamValueSerializerV1.INSTANCE.writeMap(extraData, data); } catch (IOException e) { throw new RuntimeException(e); } }
private @Nullable ReferencedEnvelope createBoundsFilter(//@formatter:off SimpleFeatureType fullSchema, List<Envelope> bounds, ObjectId featureTypeTreeId, ObjectStore treeSource) {//@formatter:on if (EMPTY_TREE_ID.equals(featureTypeTreeId)) { return null; } CoordinateReferenceSystem nativeCrs = fullSchema.getCoordinateReferenceSystem(); if (nativeCrs == null) { nativeCrs = DefaultEngineeringCRS.GENERIC_2D; } final Envelope queryBounds = new Envelope(); if (bounds != null && !bounds.isEmpty()) { final RevTree tree = treeSource.getTree(featureTypeTreeId); final Envelope fullBounds = SpatialOps.boundsOf(tree); expandToInclude(queryBounds, bounds); Envelope clipped = fullBounds.intersection(queryBounds); if (clipped.equals(fullBounds)) { queryBounds.setToNull(); } } return queryBounds.isNull() ? null : new ReferencedEnvelope(queryBounds, nativeCrs); }
@Override protected void writeBucket(final Bucket bucket, DataOutput data, Envelope envBuff) throws IOException { writeUnsignedVarInt(bucket.getIndex(), data); bucket.getObjectId().writeTo(data); envBuff.setToNull(); bucket.expand(envBuff); writeBounds(envBuff, data); }
protected void writeBucket(final Bucket bucket, DataOutput data, Envelope envBuff) throws IOException { writeUnsignedVarInt(bucket.getIndex(), data); bucket.getObjectId().writeTo(data); envBuff.setToNull(); bucket.expand(envBuff); if (envBuff.isNull()) { data.writeByte(BOUNDS_NULL_MASK); } else if (envBuff.getWidth() == 0D && envBuff.getHeight() == 0D) { data.writeByte(BOUNDS_POINT_MASK); writePointBoundingBox(envBuff.getMinX(), envBuff.getMinY(), data); } else { data.writeByte(BOUNDS_BOX2D_MASK); writeBoundingBox(envBuff.getMinX(), envBuff.getMaxX(), envBuff.getMinY(), envBuff.getMaxY(), data); } }
private void writeBuckets(Writer w, Iterable<Bucket> buckets) throws IOException { for (Bucket bucket : buckets) { print(w, TreeNode.BUCKET.name()); print(w, "\t"); print(w, String.valueOf(bucket.getIndex())); print(w, "\t"); print(w, bucket.getObjectId().toString()); print(w, "\t"); Envelope env = new Envelope(); env.setToNull(); bucket.expand(env); writeEnvelope(w, env); println(w); } }
public void testSetToNull() throws Exception { Envelope e1 = new Envelope(); assertTrue(e1.isNull()); e1.expandToInclude(5, 5); assertTrue(!e1.isNull()); e1.setToNull(); assertTrue(e1.isNull()); }
public void testEquals() throws Exception { Envelope e1 = new Envelope(1, 2, 3, 4); Envelope e2 = new Envelope(1, 2, 3, 4); assertEquals(e1, e2); assertEquals(e1.hashCode(), e2.hashCode()); Envelope e3 = new Envelope(1, 2, 3, 5); assertTrue(!e1.equals(e3)); assertTrue(e1.hashCode() != e3.hashCode()); e1.setToNull(); assertTrue(!e1.equals(e2)); assertTrue(e1.hashCode() != e2.hashCode()); e2.setToNull(); assertEquals(e1, e2); assertEquals(e1.hashCode(), e2.hashCode()); }