/** * Add a constrained to the given name of a dataset. * * @param name * @param datasourceObject * @param bbt * @param sdt * @return true if no previous mapping for the given name was found. */ protected boolean addConstraint( String name, CO datasourceObject, BoundingBoxType bbt, ScaleDenominatorsType sdt) { List<Constraint<CO>> dsConstraints = datasourceConstraints.get(name); Constraint<CO> newC = new Constraint<CO>( datasourceObject, createEnvelope(bbt, defaultCRS, null), sdt.getMin(), sdt.getMax()); if (newC.getValidEnvelope().getMin().getCoordinateDimension() != 3) { LOG.warn( "Given envelope of datasource: " + name + " is not 3 dimensional, please configure this datasource to be 3d."); } if (dsConstraints == null) { dsConstraints = new LinkedList<Constraint<CO>>(); dsConstraints.add(newC); datasourceConstraints.put(name, dsConstraints); return true; } for (Constraint<CO> c : dsConstraints) { if (c.equals(newC)) { LOG.info("Ignoring datasource it is already defined. "); return false; } if (c.minScale < newC.minScale && c.maxScale > newC.maxScale) { if (c.validEnvelope.intersects(newC.validEnvelope)) { LOG.warn("Found overlapping scales and envelopes for datasource, this may not be."); return false; } } } dsConstraints.add(newC); return true; }
/** * This method returns true if the second scale interval intersects with the first scale interval. * * @param firstScales * @param secondScales * @return true if the second scale interval intersects the first interval. */ protected boolean scalesFit( ScaleDenominatorsType firstScales, ScaleDenominatorsType secondScales) { boolean result = (firstScales == null) && (secondScales == null); if (!result) { if (firstScales != null && secondScales != null) { result = (secondScales.getMin() <= firstScales.getMax()) && (firstScales.getMin() <= secondScales.getMax()); } } return result; }
/** * return the {@link ScaleDenominatorsType} if the definedScale does is null, the parent scale * will be used. * * @param parentScale * @param definedScale * @return the {@link ScaleDenominatorsType} of the given datatype. */ private ScaleDenominatorsType clarifyScaleInheritance( ScaleDenominatorsType parentScale, ScaleDenominatorsType definedScale) { ScaleDenominatorsType result = definedScale; if (result == null) { result = parentScale; } else { if (result.getMin() < parentScale.getMin()) { LOG.info( "The minimal scale denominator is smaller than the parent scaledenominator, is this correct?"); } if (result.getMax() > parentScale.getMax()) { LOG.info( "The maximum scale denominator exceeds its parent scaledenominator, is this correct?"); } } return result; }