Пример #1
0
        internal void UpdateLayerStyle(RedlineLayer layer, RedlineStyle updatedStyle)
        {
            //HACK: SQLite leaky abstraction (hard-coded schema name), SHP probably has some leaks of its own, so we can't assume MarkupSchema:Markup
            //as the class name interrogate our schema to figure it out
            MgResourceIdentifier fsId = new MgResourceIdentifier(layer.FeatureSource);

            MgFeatureSchemaCollection   schemas = _featSvc.DescribeSchema(fsId, string.Empty, null);
            MgFeatureSchema             schema  = schemas.GetItem(0);
            MgClassDefinitionCollection classes = schema.GetClasses();
            MgClassDefinition           cls     = classes.GetItem(0);
            string className = schema.Name + ":" + cls.Name;

            MgResourceIdentifier ldfId = new MgResourceIdentifier(layer.LayerDefinition);

            string layerDefContent = CreateRedlineLayerDefinitionContent(fsId, className, updatedStyle, layer.StyleType);

            byte[]       bytes      = Encoding.UTF8.GetBytes(layerDefContent);
            MgByteSource byteSource = new MgByteSource(bytes, bytes.Length);
            MgByteReader byteReader = byteSource.GetReader();

            _resSvc.SetResource(ldfId, byteReader, null);
        }
Пример #2
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            MgFeatureSchema schema1 = new MgFeatureSchema("schema1", "desc1");
            MgFeatureSchema schema2 = new MgFeatureSchema("schema2", "desc2");
            MgFeatureSchema schema3 = new MgFeatureSchema("schema3", "desc3");

            MgFeatureSchemaCollection coll = new MgFeatureSchemaCollection();

            coll.Add(schema1);
            coll.Add(schema2);
            coll.Add(schema3);

            Assert.AreEqual(3, coll.Count);
            Assert.AreEqual("schema3", coll[2].GetName());
            coll[0] = coll[2];

            string txt = "";

            foreach (MgFeatureSchema schema in coll)
            {
                txt += "[" + schema.GetName() + "]";
            }
            Assert.AreEqual("[schema3][schema2][schema3]", txt);
        }
Пример #3
0
        public RedlineLayer CreateRedlineLayer(CreateRedlineLayerParams param, out bool bAddedToMap)
        {
            bAddedToMap = false;
            MgResourceIdentifier fsId = GenerateRedlineFeatureSourceId(param);

            string className    = null;
            string providerName = null;

            if (_resSvc.ResourceExists(fsId))
            {
                MgFeatureSchemaCollection   schemas = _featSvc.DescribeSchema(fsId, string.Empty, null);
                MgFeatureSchema             schema  = schemas.GetItem(0);
                MgClassDefinitionCollection classes = schema.GetClasses();
                MgClassDefinition           cls     = classes.GetItem(0);
                className = schema.Name + ":" + cls.Name;
            }
            else
            {
                MgFeatureSchema schema = RedlineSchemaFactory.CreateSchema(param.GeometryTypes);

                providerName = "OSGeo.SDF";
                if (param.Format == RedlineDataStoreFormat.SHP)
                {
                    providerName = "OSGeo.SHP";
                }
                else if (param.Format == RedlineDataStoreFormat.SQLite)
                {
                    providerName = "OSGeo.SQLite";
                }

                MgFileFeatureSourceParams createParams = new MgFileFeatureSourceParams(providerName, RedlineSchemaFactory.SPATIAL_CONTEXT, _map.GetMapSRS(), schema);
                _featSvc.CreateFeatureSource(fsId, createParams);

                //HACK: SQLite leaky abstraction (hard-coded schema name), SHP probably has some leaks of its own, so we can't assume MarkupSchema:Markup
                //as the class name so re-interrogate our schema to figure it out
                MgFeatureSchemaCollection schemas = _featSvc.DescribeSchema(fsId, string.Empty, null);
                schema = schemas.GetItem(0);
                MgClassDefinitionCollection classes = schema.GetClasses();
                MgClassDefinition           cls     = classes.GetItem(0);
                className = schema.Name + ":" + cls.Name;
            }

            MgResourceIdentifier ldfId = GenerateRedlineLayerDefinitionId(param);

            if (!_resSvc.ResourceExists(ldfId))
            {
                string       layerDefContent = CreateRedlineLayerDefinitionContent(fsId, className, param.Style, param.StyleType);
                byte[]       bytes           = Encoding.UTF8.GetBytes(layerDefContent);
                MgByteSource byteSource      = new MgByteSource(bytes, bytes.Length);
                MgByteReader byteReader      = byteSource.GetReader();

                _resSvc.SetResource(ldfId, byteReader, null);
            }

            if (param.AddToMap)
            {
                AddRedlineLayerToMap(ldfId);
                bAddedToMap = true;
            }

            var layer = new RedlineLayer(ldfId.Name, fsId.ToString(), ldfId.ToString(), param.GeometryTypes, param.StyleType);

            //If provider name was set, then we register this layer in the registry. Otherwise it means
            //the layer already exists and by extension already registered
            if (providerName != null)
            {
                _registry.AddRedlineLayer(layer, providerName);
            }
            return(layer);
        }
Пример #4
0
        public void FeatureSchemaCollection()
        {
            MgFeatureSchema schema1 = new MgFeatureSchema("schema1", "desc1");
            MgFeatureSchema schema2 = new MgFeatureSchema("schema2", "desc2");
            MgFeatureSchema schema3 = new MgFeatureSchema("schema3", "desc3");

            MgFeatureSchemaCollection coll = new MgFeatureSchemaCollection();
            coll.Add(schema1);
            coll.Add(schema2);
            coll.Add(schema3);

            Assert.AreEqual(3, coll.Count);
            Assert.AreEqual("schema3", coll[2].GetName());
            coll[0] = coll[2];

            string txt = "";
            foreach (MgFeatureSchema schema in coll)
            {
                txt += "[" + schema.GetName() + "]";
            }
            Assert.AreEqual("[schema3][schema2][schema3]", txt);
        }