Search in sources :

Example 1 with InternationalString

use of org.opengis.util.InternationalString in project sldeditor by robward-scisys.

the class UniqueValueRenderer method convert.

/* (non-Javadoc)
     * @see com.sldeditor.convert.esri.renderer.EsriRendererInterface#convert(com.google.gson.JsonObject, java.lang.String, double, double, int)
     */
@Override
public StyledLayerDescriptor convert(JsonObject json, String layerName, double minScale, double maxScale, int transparency) {
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    boolean useDefaultSymbol = false;
    JsonElement useDefaultSymbolElement = json.get(UniqueValueRendererKeys.USE_DEFAULTSYMBOL);
    if (useDefaultSymbolElement != null) {
        useDefaultSymbol = useDefaultSymbolElement.getAsBoolean();
    }
    JsonElement jsonElement = json.get(CommonRendererKeys.LABEL);
    if (jsonElement != null) {
        namedLayer.setName(jsonElement.getAsString());
    }
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    // style.setAbstract(json.get(IntermediateFileKeys.DESCRIPTION).getAsString());
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    JsonElement element = json.get(UniqueValueRendererKeys.VALUES);
    if (element != null) {
        JsonArray valueList = element.getAsJsonArray();
        for (int index = 0; index < valueList.size(); index++) {
            JsonElement valueElement = valueList.get(index);
            if (valueElement != null) {
                Rule rule = styleFactory.createRule();
                JsonObject valueObj = valueElement.getAsJsonObject();
                String value = getString(valueObj, UniqueValueRendererKeys.VALUES_VALUE);
                String label = getString(valueObj, UniqueValueRendererKeys.VALUES_LABEL);
                rule.setName(label);
                createFilter(rule, json.get(UniqueValueRendererKeys.FIELDS), json.get(UniqueValueRendererKeys.FIELD_DELIMETER), value);
                // Heading /description
                String heading = getString(valueObj, UniqueValueRendererKeys.VALUES_HEADING);
                @SuppressWarnings("unused") String description = getString(valueObj, UniqueValueRendererKeys.VALUES_DESCRIPTION);
                if ((heading != null) && !heading.isEmpty() || (label != null) && !label.isEmpty()) {
                    if (label == null) {
                        label = "";
                    }
                    InternationalString titleString = Text.text(label);
                    if (heading == null) {
                        heading = "";
                    }
                    InternationalString descriptionString = Text.text(heading);
                    Description descriptionObj = styleFactory.description(titleString, descriptionString);
                    rule.setDescription(descriptionObj);
                }
                if (minScale > 0.0) {
                    rule.setMinScaleDenominator(minScale);
                }
                if (maxScale > 0.0) {
                    rule.setMaxScaleDenominator(maxScale);
                }
                JsonElement jsonSymbolElement = valueObj.get(UniqueValueRendererKeys.VALUES_SYMBOL);
                SymbolManager.getInstance().convertSymbols(rule, layerName, transparency, jsonSymbolElement);
                if (useDefaultSymbol && value == null) {
                    rule.setIsElseFilter(true);
                }
                fts.rules().add(rule);
            }
        }
    }
    return sld;
}
Also used : Description(org.geotools.styling.Description) JsonObject(com.google.gson.JsonObject) InternationalString(org.opengis.util.InternationalString) JsonArray(com.google.gson.JsonArray) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) InternationalString(org.opengis.util.InternationalString) JsonElement(com.google.gson.JsonElement) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 2 with InternationalString

use of org.opengis.util.InternationalString in project sldeditor by robward-scisys.

the class StandardPanel method getStandardData.

/**
 * Gets the standard data.
 *
 * @return the standard data
 */
protected StandardData getStandardData() {
    StandardData standardData = new StandardData();
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.NAME) != null) {
        standardData.name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
    }
    if ((fieldConfigVisitor.getFieldConfig(FieldIdEnum.TITLE) != null) && (fieldConfigVisitor.getFieldConfig(FieldIdEnum.DESCRIPTION) != null)) {
        InternationalString titleString = Text.text(fieldConfigVisitor.getText(FieldIdEnum.TITLE));
        InternationalString descriptionString = Text.text(fieldConfigVisitor.getText(FieldIdEnum.DESCRIPTION));
        standardData.description = (Description) getStyleFactory().description(titleString, descriptionString);
    }
    FieldConfigBase uomFieldConfig = fieldConfigManager.get(FieldIdEnum.UOM);
    if (uomFieldConfig != null) {
        Expression uomExpression = fieldConfigVisitor.getExpression(FieldIdEnum.UOM);
        String uomString = "";
        if (uomExpression instanceof LiteralExpressionImpl) {
            uomString = (String) ((LiteralExpressionImpl) uomExpression).getValue();
        } else {
            if (uomExpression != null) {
                ConsoleManager.getInstance().error(this, Localisation.getString(StandardPanel.class, "StandardPanel.unsupportedUOM") + uomExpression.getClass().getName());
            }
        }
        standardData.unit = UnitsOfMeasure.getInstance().convert(uomString);
    }
    return standardData;
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) InternationalString(org.opengis.util.InternationalString) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) InternationalString(org.opengis.util.InternationalString)

Example 3 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class DefaultLocalName method castOrCopy.

/**
 * Returns a SIS local name implementation with the values of the given arbitrary implementation.
 * This method performs the first applicable action in the following choices:
 *
 * <ul>
 *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
 *   <li>Otherwise if the given object is an instance of {@link MemberName} or {@link TypeName},
 *       then this method delegates to {@code castOrCopy(…)} method of the corresponding subclass.</li>
 *   <li>Otherwise if the given object is already an instance of {@code DefaultLocalName},
 *       then it is returned unchanged.</li>
 *   <li>Otherwise a new {@code DefaultLocalName} instance is created
 *       with the same values than the given name.</li>
 * </ul>
 *
 * @param  object  the object to get as a SIS implementation, or {@code null} if none.
 * @return a SIS implementation containing the values of the given object (may be the
 *         given object itself), or {@code null} if the argument was null.
 */
public static DefaultLocalName castOrCopy(final LocalName object) {
    if (object instanceof MemberName) {
        return DefaultMemberName.castOrCopy((MemberName) object);
    }
    if (object instanceof TypeName) {
        return DefaultTypeName.castOrCopy((TypeName) object);
    }
    if (object == null || object instanceof DefaultLocalName) {
        return (DefaultLocalName) object;
    }
    final NameSpace scope = object.scope();
    final InternationalString name = object.toInternationalString();
    if (scope instanceof DefaultNameSpace) {
        // May return a cached instance.
        return ((DefaultNameSpace) scope).local(name, null);
    } else {
        return new DefaultLocalName(scope, name);
    }
}
Also used : TypeName(org.opengis.util.TypeName) InternationalString(org.opengis.util.InternationalString) NameSpace(org.opengis.util.NameSpace) MemberName(org.opengis.util.MemberName)

Example 4 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class DefaultExtent method intersect.

/**
 * Sets this extent to the intersection of this extent with the specified one.
 * This method computes the intersections of all geographic, vertical and temporal elements in this extent
 * with all geographic, vertical and temporal elements in the other extent, ignoring duplicated results.
 *
 * @param  other  the extent to intersect with this extent.
 * @throws IllegalArgumentException if two elements to intersect are not compatible (e.g. mismatched
 *         {@linkplain DefaultGeographicBoundingBox#getInclusion() bounding box inclusion status} or
 *         mismatched {@linkplain DefaultVerticalExtent#getVerticalCRS() vertical datum}).
 * @throws UnsupportedOperationException if a {@code TemporalFactory} is required but no implementation
 *         has been found on the classpath.
 *
 * @see Extents#intersection(Extent, Extent)
 * @see org.apache.sis.geometry.GeneralEnvelope#intersect(Envelope)
 *
 * @since 0.8
 */
public void intersect(final Extent other) {
    checkWritePermission();
    ArgumentChecks.ensureNonNull("other", other);
    final InternationalString od = other.getDescription();
    if (od != null && !(description instanceof NilObject)) {
        if (description == null || (od instanceof NilObject)) {
            description = od;
        } else if (!description.equals(od)) {
            description = NilReason.MISSING.createNilObject(InternationalString.class);
        }
    }
    geographicElements = intersect(GeographicExtent.class, geographicElements, other.getGeographicElements(), Extents::intersection);
    verticalElements = intersect(VerticalExtent.class, verticalElements, other.getVerticalElements(), Extents::intersection);
    temporalElements = intersect(TemporalExtent.class, temporalElements, other.getTemporalElements(), Extents::intersection);
}
Also used : TemporalExtent(org.opengis.metadata.extent.TemporalExtent) InternationalString(org.opengis.util.InternationalString) VerticalExtent(org.opengis.metadata.extent.VerticalExtent) NilObject(org.apache.sis.xml.NilObject) GeographicExtent(org.opengis.metadata.extent.GeographicExtent)

Example 5 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class TransformCommand method printDomainOfValidity.

/**
 * Prints a textual description of the domain of validity. This method tries to reduce the string length by
 * the use of some heuristic rules based on the syntax used in EPSG dataset. For example the following string:
 *
 * <blockquote>Canada - onshore and offshore - Alberta; British Columbia (BC); Manitoba; New Brunswick (NB);
 * Newfoundland and Labrador; Northwest Territories (NWT); Nova Scotia (NS); Nunavut; Ontario; Prince Edward
 * Island (PEI); Quebec; Saskatchewan; Yukon.</blockquote>
 *
 * is replaced by:
 *
 * <blockquote>Canada - onshore and offshore</blockquote>
 */
private void printDomainOfValidity(final Extent domain) throws IOException {
    if (domain != null) {
        final InternationalString description = domain.getDescription();
        if (description != null) {
            String text = description.toString(locale);
            if (text.length() >= 80) {
                int end = text.indexOf(';');
                if (end >= 0) {
                    int s = text.lastIndexOf('-', end);
                    if (s >= 0) {
                        end = s;
                    }
                    text = text.substring(0, end).trim();
                }
            }
            printHeader(Vocabulary.Keys.Domain);
            outHeader.append(text);
            outHeader.nextLine();
        }
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) InternationalString(org.opengis.util.InternationalString)

Aggregations

InternationalString (org.opengis.util.InternationalString)86 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)20 Test (org.junit.Test)17 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)13 IdentifiedObject (org.opengis.referencing.IdentifiedObject)10 ArrayList (java.util.ArrayList)7 Locale (java.util.Locale)6 GenericName (org.opengis.util.GenericName)6 Extent (org.opengis.metadata.extent.Extent)5 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 Vocabulary (org.apache.sis.util.resources.Vocabulary)4 Citation (org.opengis.metadata.citation.Citation)4 IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableAppender (org.apache.sis.io.TableAppender)3 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)3 DataStoreException (org.apache.sis.storage.DataStoreException)3