コード例 #1
0
        /// <summary>
        /// Convenience method.
        /// </summary>
        /// <param name="file">
        ///            the path to the output file </param>
        public virtual void loadTagMappingFile(string file)
        {
            if (!string.ReferenceEquals(file, null))
            {
                File f = new File(file);
                if (!f.exists())
                {
                    throw new System.ArgumentException("tag mapping file parameter points to a file that does not exist");
                }
                if (f.Directory)
                {
                    throw new System.ArgumentException("tag mapping file parameter points to a directory, must be a file");
                }
                else if (!f.canRead())
                {
                    throw new System.ArgumentException("tag mapping file parameter points to a file we have no read permissions");
                }

                try
                {
                    this.tagMapping = OSMTagMapping.getInstance(f.toURI().toURL());
                }
                catch (MalformedURLException e)
                {
                    throw new Exception(e);
                }
            }
            else
            {
                this.tagMapping = OSMTagMapping.Instance;
            }
        }
コード例 #2
0
ファイル: OSMUtils.cs プロジェクト: tilemapjp/MapsforgeSharp
        /// <summary>
        /// Extracts known way tags and returns their ids.
        /// </summary>
        /// <param name="entity">
        ///            the way </param>
        /// <returns> the ids of the identified tags </returns>
        public static short[] extractKnownWayTags(Entity entity)
        {
            TShortArrayList currentTags = new TShortArrayList();
            OSMTagMapping   mapping     = OSMTagMapping.Instance;

            if (entity.Tags != null)
            {
                foreach (Tag tag in entity.Tags)
                {
                    OSMTag wayTag = mapping.getWayTag(tag.Key, tag.Value);
                    if (wayTag != null)
                    {
                        currentTags.add(wayTag.Id);
                    }
                }
            }
            return(currentTags.toArray());
        }