Ejemplo n.º 1
0
        internal MapFileWriterTask(MapWriterConfiguration configuration)
        {
            this.configuration = configuration;

            Properties properties = new Properties();

            try
            {
                properties.load(typeof(MapFileWriterTask).ClassLoader.getResourceAsStream("default.properties"));
                configuration.WriterVersion = Constants.CREATOR_NAME + "-" + properties.getProperty(Constants.PROPERTY_NAME_WRITER_VERSION);
                // If multilingual map then set newer map file version
                bool multilingual = configuration.PreferredLanguages != null && configuration.PreferredLanguages.size() > 1;
                configuration.FileSpecificationVersion = int.Parse(properties.getProperty(multilingual ? Constants.PROPERTY_NAME_FILE_SPECIFICATION_VERSION_MAX : Constants.PROPERTY_NAME_FILE_SPECIFICATION_VERSION_MIN));

                LOGGER.info("mapfile-writer version: " + configuration.WriterVersion);
                LOGGER.info("mapfile format specification version: " + configuration.FileSpecificationVersion);
            }
            catch (IOException e)
            {
                throw new Exception("could not find default properties", e);
            }
            catch (System.FormatException e)
            {
                throw new Exception("map file specification version is not an integer", e);
            }

            // CREATE DATASTORE IF BBOX IS DEFINED
            if (this.configuration.BboxConfiguration != null)
            {
                if ("ram".Equals(configuration.DataProcessorType, StringComparison.CurrentCultureIgnoreCase))
                {
                    this.tileBasedGeoObjectStore = RAMTileBasedDataProcessor.newInstance(configuration);
                }
                else
                {
                    this.tileBasedGeoObjectStore = HDTileBasedDataProcessor.newInstance(configuration);
                }
            }
        }
Ejemplo n.º 2
0
        public override void process(EntityContainer entityContainer)
        {
            Entity entity = entityContainer.Entity;

            switch (entity.Type)
            {
            case Bound:
                Bound bound = (Bound)entity;
                if (this.configuration.BboxConfiguration == null)
                {
                    BoundingBox bbox = new BoundingBox(bound.Bottom, bound.Left, bound.Top, bound.Right);
                    this.configuration.BboxConfiguration = bbox;
                    this.configuration.validate();
                    if ("ram".Equals(this.configuration.DataProcessorType))
                    {
                        this.tileBasedGeoObjectStore = RAMTileBasedDataProcessor.newInstance(this.configuration);
                    }
                    else
                    {
                        this.tileBasedGeoObjectStore = HDTileBasedDataProcessor.newInstance(this.configuration);
                    }
                }
                LOGGER.info("start reading data...");
                break;

            // *******************************************************
            // ****************** NODE PROCESSING*********************
            // *******************************************************
            case Node:

                if (this.tileBasedGeoObjectStore == null)
                {
                    LOGGER.severe("No valid bounding box found in input data.\n" + "Please provide valid bounding box via command " + "line parameter 'bbox=minLat,minLon,maxLat,maxLon'.\n" + "Tile based data store not initialized. Aborting...");
                    throw new System.InvalidOperationException("tile based data store not initialized, missing bounding " + "box information in input data");
                }
                this.tileBasedGeoObjectStore.addNode((Node)entity);
                // hint to GC
                entity = null;
                this.amountOfNodesProcessed++;
                break;

            // *******************************************************
            // ******************* WAY PROCESSING*********************
            // *******************************************************
            case Way:
                this.tileBasedGeoObjectStore.addWay((Way)entity);
                entity = null;
                this.amountOfWaysProcessed++;
                break;

            // *******************************************************
            // ****************** RELATION PROCESSING*********************
            // *******************************************************
            case Relation:
                Relation currentRelation = (Relation)entity;
                this.tileBasedGeoObjectStore.addRelation(currentRelation);
                this.amountOfRelationsProcessed++;
                entity = null;
                break;
            }
        }