⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 featuretypeinfo.java

📁 电子地图服务器,搭建自己的地图服务
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * @return Short description of FeatureType
     */
    public String getAbstract() {
        return _abstract;
    }

    /**
     * Keywords describing content of FeatureType.
     *
     * <p>
     * Keywords are often used by Search engines or Catalog services.
     * </p>
     *
     * @return List the FeatureTypeInfo keywords
     */
    public List getKeywords() {
        return keywords;
    }

    /**
     * Metadata links providing metadata access for FeatureTypes.
     *
     * @return List the FeatureTypeInfo metadata links
     */
    public List getMetadataLinks() {
        return metadataLinks;
    }

    /**
     * getTitle purpose.
     *
     * <p>
     * returns the FeatureTypeInfo title
     * </p>
     *
     * @return String the FeatureTypeInfo title
     */
    public String getTitle() {
        return title;
    }

    /**
     * A valid schema name for this FeatureType.
     *
     * @return schemaName if provided or typeName+"_Type"
     */
    public String getSchemaName() {
        if (schemaName == null) {
            return typeName + "_Type";
        }

        return schemaName;
    }

    /**
     * setSchemaName purpose.
     *
     * <p>
     * Description ...
     * </p>
     *
     * @param string
     */
    public void setSchemaName(String string) {
        schemaName = string;
    }

    /**
     * getSchemaName purpose.
     *
     * <p>
     * Description ...
     * </p>
     *
     * @return
     */
    public String getSchemaBase() {
        return schemaBase;
    }

    /**
     * setSchemaName purpose.
     *
     * <p>
     * Description ...
     * </p>
     *
     * @param string
     */
    public void setSchemaBase(String string) {
        schemaBase = string;
    }

    //
    // FeatureTypeMetaData Interface
    //
    /**
     * Access the name of this FeatureType.
     * <p>
     * This is the typeName as provided by the real gt2 DataStore.
     * </p>
     *
     * @return String getName()
     * @see org.geotools.data.FeatureTypeMetaData#getTypeName()
     */
    public String getTypeName() {
        return typeName;
    }

    /**
     * Access real geotools2 FeatureType.
     *
     * @return Schema information.
     *
     * @throws IOException
     *
     * @see org.geotools.data.FeatureTypeMetaData#getFeatureType()
     */
    public FeatureType getFeatureType() throws IOException {
        return getFeatureType(getFeatureSource());
    }

    /**
     * Fixes the data store feature type so that it has the right CRS (only in case they are missing)
     * and the requiered base attributes
     */
    private FeatureType getFeatureType(FeatureSource fs)
        throws IOException {
        if (ft == null) {
            int count = 0;
            ft = fs.getSchema();

            URI namespace = ft.getNamespace(); //DJB:: change to #getNamespace() due to API change

            String[] baseNames = DataTransferObjectFactory.getRequiredBaseAttributes(schemaBase);
            AttributeType[] attributes = new AttributeType[schema.size() + baseNames.length];

            if (attributes.length > 0) {
                int errors = 0;

                for (; count < baseNames.length; count++) {
                    attributes[count - errors] = ft.getAttributeType(baseNames[count]);

                    if (attributes[count - errors] == null) {
                        // desired base attr is not availiable
                        errors++;
                    }
                }

                if (errors != 0) {
                    //resize array;
                    AttributeType[] tmp = new AttributeType[attributes.length - errors];
                    count = count - errors;

                    for (int i = 0; i < count; i++) {
                        tmp[i] = attributes[i];
                    }

                    attributes = tmp;
                }

                for (Iterator i = schema.iterator(); i.hasNext();) {
                    AttributeTypeInfo ati = (AttributeTypeInfo) i.next();
                    String attName = ati.getName();
                    attributes[count] = ft.getAttributeType(attName);

                    // force the user specified CRS if the data has no CRS, or reproject it 
                    // if necessary
                    if (Geometry.class.isAssignableFrom(attributes[count].getType())) {
                        GeometricAttributeType old = (GeometricAttributeType) attributes[count];

                        try {
                            if (old.getCoordinateSystem() == null) {
                                attributes[count] = new GeometricAttributeType(old, getSRS(SRS));
                                srsHandling = FORCE;
                            } else if(srsHandling == REPROJECT || srsHandling == FORCE) {
                                attributes[count] = new GeometricAttributeType(old, getSRS(SRS));
                            }
                        } catch (Exception e) {
                            e.printStackTrace(); //DJB: this is okay to ignore since (a) it should never happen (b) we'll use the default one (crs=null)
                        }
                    }

                    if (attributes[count] == null) {
                        throw new IOException("the FeatureType " + getName()
                            + " does not contains the configured attribute " + attName
                            + ". Check your schema configuration");
                    }

                    count++;
                }

                try {
                    ft = FeatureTypeFactory.newFeatureType(attributes, typeName, namespace);
                } catch (SchemaException ex) {
                } catch (FactoryConfigurationError ex) {
                }
            }
        }

        return ft;
    }

    /**
     * Implement getDataStoreMetaData.
     *
     * @return
     *
     * @see org.geotools.data.FeatureTypeMetaData#getDataStoreMetaData()
     */
    public DataStoreInfo getDataStoreMetaData() {
        return data.getDataStoreInfo(dataStoreId);
    }

    /**
     * FeatureType attributes names as a List.
     *
     * <p>
     * Convience method for accessing attribute names as a Collection. You may
     * use the names for AttributeTypeMetaData lookup or with the schema for
     * XPATH queries.
     * </p>
     *
     * @return List of attribute names
     *
     * @task REVISIT: This method sucks.  It didn't do the same thing as
     *       getAttributes, which it should have.  I fixed the root problem of
     *       why attribs.size() would equal 0.  So the second half of this
     *       method should probably be eliminated, as it should never be
     *       called. But I don't want to break code right before a release -
     *       ch.
     *
     * @see org.geotools.data.FeatureTypeMetaData#getAttributeNames()
     */
    public List getAttributeNames() {
        List attribs = schema;

        if (attribs.size() != 0) {
            List list = new ArrayList(attribs.size());

            for (Iterator i = attribs.iterator(); i.hasNext();) {
                AttributeTypeInfo at = (AttributeTypeInfo) i.next();
                list.add(at.getName());
            }

            return list;
        }

        List list = new ArrayList();

        try {
            FeatureType ftype = getFeatureType();
            AttributeType[] types = ftype.getAttributeTypes();
            list = new ArrayList(types.length);

            for (int i = 0; i < types.length; i++) {
                list.add(types[i].getName());
            }
        } catch (IOException e) {
        }

        return list;
    }

    /**
     * Returns a list of the attributeTypeInfo objects that make up this
     * FeatureType.
     *
     * @return list of attributeTypeInfo objects.
     */
    public List getAttributes() {
        return schema;
    }

    /**
     * Implement AttributeTypeMetaData.
     *
     * <p>
     * Description ...
     * </p>
     *
     * @param attributeName
     *
     * @return
     *
     * @see org.geotools.data.FeatureTypeMetaData#AttributeTypeMetaData(java.lang.String)
     */
    public synchronized AttributeTypeInfo AttributeTypeMetaData(String attributeName) {
        AttributeTypeInfo info = null;

        if (schema != null) {
            for (Iterator i = schema.iterator(); i.hasNext();) {
                AttributeTypeInfoDTO dto = (AttributeTypeInfoDTO) i.next();
                info = new AttributeTypeInfo(dto);
            }

            DataStore dataStore = data.getDataStoreInfo(dataStoreId).getDataStore();

            try {
                FeatureType ftype = dataStore.getSchema(typeName);
                info.sync(ftype.getAttributeType(attributeName));
            } catch (IOException e) {
            }
        } else {
            // will need to generate from Schema
            DataStore dataStore = data.getDataStoreInfo(dataStoreId).getDataStore();

            try {
                FeatureType ftype = dataStore.getSchema(typeName);
                info = new AttributeTypeInfo(ftype.getAttributeType(attributeName));
            } catch (IOException e) {
            }
        }

        return info;
    }

    /**
     * Implement containsMetaData.
     *
     * @param key
     *
     * @return
     *
     * @see org.geotools.data.MetaData#containsMetaData(java.lang.String)
     */
    public boolean containsMetaData(String key) {
        return meta.containsKey(key);
    }

    /**
     * Implement putMetaData.
     *
     * @param key
     * @param value
     *
     * @see org.geotools.data.MetaData#putMetaData(java.lang.String,
     *      java.lang.Object)
     */
    public void putMetaData(String key, Object value) {
        meta.put(key, value);
    }

    /**
     * Implement getMetaData.
     *
     * @param key
     *
     * @return
     *
     * @see org.geotools.data.MetaData#getMetaData(java.lang.String)
     */
    public Object getMetaData(String key) {
        return meta.get(key);
    }

    /**
     * getLegendURL purpose.
     *
     * <p>
     * returns the FeatureTypeInfo legendURL
     * </p>
     *
     * @return String the FeatureTypeInfo legendURL
     */

    // Modif C. Kolbowicz - 07/10/2004
    public LegendURL getLegendURL() {
        return this.legendURL;
    }

    //-- Modif C. Kolbowicz - 07/10/2004

    /**
     * Gets the schema.xml file associated with this FeatureType.  This is set
     * during the reading of configuration, it is not persisted as an element
     * of the FeatureTypeInfoDTO, since it is just whether the schema.xml file
     * was persisted, and its location.  If there is no schema.xml file then
     * this method will return a File object with the location where the schema
     * file would be located, but the file will return false for exists().
     */
    public File getSchemaFile() {
        return this.schemaFile;
    }

    /**
     *  simple way of getting epsg #.
     *  We cache them so that we dont have to keep reading the DB or the epsg.properties file.
     *   I cannot image a system with more than a dozen CRSs in it...
     *
     * @param epsg
     * @return
     */
    private CoordinateReferenceSystem getSRS(int epsg) {
        CoordinateReferenceSystem result = (CoordinateReferenceSystem) SRSLookup.get(new Integer(
                    epsg));

        if (result == null) {
            //make and add to hash
            try {
                result = CRS.decode("EPSG:" + epsg);
                SRSLookup.put(new Integer(epsg), result);
            } catch (NoSuchAuthorityCodeException e) {
                String msg = "Error looking up SRS for EPSG: " + epsg + ":"
                    + e.getLocalizedMessage();
                LOGGER.warning(msg);
            } catch (FactoryException e) {
                String msg = "Error looking up SRS for EPSG: " + epsg + ":"
                    + e.getLocalizedMessage();
                LOGGER.warning(msg);
            }
        }

        return result;
    }

    public String getDirName() {
        return dirName;
    }

    public String getWmsPath() {
        return wmsPath;
    }

    public void setWmsPath(String wmsPath) {
        this.wmsPath = wmsPath;
    }

    /**
     * This value is added the headers of generated maps, marking them as being both
     * "cache-able" and designating the time for which they are to remain valid.
     *  The specific header added is "Cache-Control: max-age="
     * @return a string representing the number of seconds to be added to the "Cache-Control: max-age=" header
     */
    public String getCacheMaxAge() {
        return cacheMaxAge;
    }

    /**
     *
     * @param cacheMaxAge a string representing the number of seconds to be added to the "Cache-Control: max-age=" header
     */
    public void setCacheMaxAge(String cacheMaxAge) {
        this.cacheMaxAge = cacheMaxAge;
    }

    /**
     * Should we add the cache-control: max-age header to maps containing this layer?
     * @return true if we should, false if we should omit the header
     */
    public boolean isCachingEnabled() {
        return cachingEnabled;
    }

    /**
     * Sets whether we should add the cache-control: max-age header to maps containing this layer
     * @param cachingEnabled true if we should add the header, false if we should omit the header
     */
    public void setCachingEnabled(boolean cachingEnabled) {
        this.cachingEnabled = cachingEnabled;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -