Ejemplo n.º 1
0
 public abstract void RenderOsmObject(
     MapMakerSettings mapMakerSettings,
     MapDataAnalysis analysis,
     InMemoryOsmDatabase osmDatabase,
     OsmObjectBase osmObject,
     OsmRelation parentRelation,
     CGpsMapperMapWriter mapWriter);
Ejemplo n.º 2
0
        public OsmObjectMother LoadFromFile(string fileName)
        {
            osmDatabase = new InMemoryOsmDatabase();
            OsmXmlReader osmXmlReader = new OsmXmlReader();

            osmXmlReader.Read(fileName, new WindowsFileSystem(), osmDatabase);

            osmDatabase.RemoveWaysWithMissingNodes();

            return(this);
        }
Ejemplo n.º 3
0
        public InMemoryOsmDatabase Provide()
        {
            InMemoryOsmDatabase osmDatabase = new InMemoryOsmDatabase();

            for (int i = 0; i < pointTypesCount; i++)
            {
                OsmNode node = new OsmNode(i + 1, 15 + (i % width) * 0.1, 46 + (i / width) * 0.1);
                node.SetTag("garmin_icon", i.ToString(CultureInfo.InvariantCulture));
                osmDatabase.AddNode(node);
            }

            return(osmDatabase);
        }
Ejemplo n.º 4
0
        public InMemoryOsmDatabase Provide()
        {
            consoleLogger.WriteLine(log, Level.Info, "Loading OSM file '{0}'...", osmFileName);

            InMemoryOsmDatabase osmDatabase  = new InMemoryOsmDatabase();
            OsmXmlReader        osmXmlReader = new OsmXmlReader();

            osmXmlReader.Read(osmFileName, fileSystem, osmDatabase);

            osmDatabase.RemoveWaysWithMissingNodes();

            return(osmDatabase);
        }
Ejemplo n.º 5
0
        private static OrderedSet <int> FindLayersUsed(InMemoryOsmDatabase osmDatabase)
        {
            OrderedSet <int> layersUsed = new OrderedSet <int>();

            OsmDataQueryParameters queryParameters = new OsmDataQueryParameters();

            queryParameters.FetchTags    = true;
            queryParameters.SkipUntagged = true;

            foreach (OsmWay way in osmDatabase.Ways)
            {
                int layer = GetOsmObjectLayerNumber(way);
                if (false == layersUsed.Contains(layer))
                {
                    layersUsed.Add(layer);
                }
            }

            return(layersUsed);
        }
Ejemplo n.º 6
0
        public override void RenderOsmObject(
            MapMakerSettings mapMakerSettings,
            MapDataAnalysis analysis,
            InMemoryOsmDatabase osmDatabase,
            OsmObjectBase osmObject,
            OsmRelation parentRelation,
            CGpsMapperMapWriter mapWriter)
        {
            mapWriter.AddSection("POLYGON")
            .AddTypeReference(TypeRegistration)
            .AddCoordinates(
                "Data",
                analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel],
                GetNodesForWay(osmDatabase, (OsmWay)osmObject));

            // rendering of holes
            if (osmObject is OsmAreaWithHoles)
            {
                OsmAreaWithHoles areaWithHoles = (OsmAreaWithHoles)osmObject;
                foreach (int holeWayId in areaWithHoles.EnumerateHolesWaysIds())
                {
                    OsmWay holeWay = osmDatabase.GetWay(holeWayId);
                    if (holeWay.NodesCount > 3)
                    {
                        mapWriter.AddCoordinates(
                            "Data",
                            analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel],
                            GetNodesForWay(osmDatabase, holeWay));
                    }
                }
            }

            mapWriter
            .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel])
            ;

            if (this.TypeRegistration.Label != null && false == this.TypeRegistration.Label.IsConstant)
            {
                mapWriter.Add("Label", this.TypeRegistration.Label.BuildLabel(mapMakerSettings, osmObject, parentRelation));
            }
        }
Ejemplo n.º 7
0
        public override void RenderOsmObject(
            MapMakerSettings mapMakerSettings,
            MapDataAnalysis analysis,
            InMemoryOsmDatabase osmDatabase,
            OsmObjectBase osmObject,
            OsmRelation parentRelation,
            CGpsMapperMapWriter mapWriter)
        {
            mapWriter.AddSection("POI")
            .AddTypeReference(TypeRegistration);

            // find the location to put the icon on
            OsmNode iconNode = null;

            if (osmObject is OsmNode)
            {
                iconNode = (OsmNode)osmObject;
            }
            else if (osmObject is OsmWay)
            {
                PointD2 location = Brejc.OsmLibrary.Helpers.OsmGeometryUtils.FindAreaCenterPoint(
                    (OsmWay)osmObject,
                    osmDatabase);
                iconNode = new OsmNode(1, location.X, location.Y);
            }
            else
            {
                throw new InvalidOperationException("Internal error.");
            }

            mapWriter
            .AddCoordinates("Data", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel], iconNode)
            .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel])
            ;

            if (this.TypeRegistration.Label != null && false == this.TypeRegistration.Label.IsConstant)
            {
                mapWriter.Add("Label", this.TypeRegistration.Label.BuildLabel(mapMakerSettings, osmObject, parentRelation));
            }
        }
Ejemplo n.º 8
0
        public override void RenderOsmObject(
            MapMakerSettings mapMakerSettings,
            MapDataAnalysis analysis,
            InMemoryOsmDatabase osmDatabase,
            OsmObjectBase osmObject,
            OsmRelation parentRelation,
            CGpsMapperMapWriter mapWriter)
        {
            mapWriter.AddSection("POLYLINE")
            .AddTypeReference(TypeRegistration)
            .AddCoordinates(
                "Data",
                analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel],
                GetNodesForWay(osmDatabase, (OsmWay)osmObject))
            .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel])
            ;

            if (this.TypeRegistration.Label != null && false == this.TypeRegistration.Label.IsConstant)
            {
                mapWriter.Add("Label", this.TypeRegistration.Label.BuildLabel(mapMakerSettings, osmObject, parentRelation).ToUpperInvariant());
            }
        }
Ejemplo n.º 9
0
 public MultipolygonRelationsProcessor(InMemoryOsmDatabase osmDatabase)
 {
     throw new System.NotImplementedException();
 }