Beispiel #1
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            var       build = new GeomBuild();
            MgPolygon geom1 = build.CreatePolygon(2.0);
            MgPolygon geom2 = build.CreatePolygon(12.0);
            MgPolygon geom3 = build.CreatePolygon(2.0);

            MgPolygonCollection coll = new MgPolygonCollection();

            coll.Add(geom1);
            coll.Add(geom2);
            coll.Add(geom3);

            Assert.AreEqual(3, coll.Count);
            Assert.IsTrue(geom1.Equals(coll[0]));
            Assert.IsTrue(coll[0].Equals(coll[2]));
            Assert.IsFalse(coll[0].Equals(coll[1]));
            coll[0] = coll[1];
            Assert.IsTrue(coll[0].Equals(coll[1]));

            double width = 0.0;

            foreach (MgPolygon geom in coll)
            {
                width += geom.Envelope().GetWidth();
            }
            Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
        }
Beispiel #2
0
        public MgMultiPolygon CreateMultiPolygon()
        {
            MgPolygon polygon1 = CreatePolygon(0.0);
            MgPolygon polygon2 = CreatePolygon(0.0);

            MgPolygonCollection polygons = new MgPolygonCollection();

            polygons.Add(polygon1);
            polygons.Add(polygon2);

            return(factory.CreateMultiPolygon(polygons));
        }
Beispiel #3
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            MgGeometryFactory      gf          = new MgGeometryFactory();
            MgCoordinate           pt1         = gf.CreateCoordinateXY(0, 0);
            MgCoordinate           pt2         = gf.CreateCoordinateXY(0, 10);
            MgCoordinate           pt3         = gf.CreateCoordinateXY(10, 10);
            MgCoordinate           pt4         = gf.CreateCoordinateXY(10, 0);
            MgCoordinateCollection coordinates = new MgCoordinateCollection();

            coordinates.Add(pt1);
            coordinates.Add(pt2);
            coordinates.Add(pt3);
            coordinates.Add(pt4);
            MgLinearRing linearRing = gf.CreateLinearRing(coordinates);
            MgPolygon    polygon    = gf.CreatePolygon(linearRing, null);

            Assert.AreEqual(linearRing.ToString(), polygon.ExteriorRing.ToString());
            Assert.AreEqual(0, polygon.InteriorRingCount);
            Assert.AreEqual(MgGeometryType.Polygon, polygon.GeometryType);
            Assert.AreEqual(2, polygon.Dimension);
        }
Beispiel #4
0
    //---------------------------------------------------------------------------------------
    //
    //        ���ܣ�����Ҫ�ض���
    //
    //         ���ߣ�
    //
    //         ���ڣ� 2007.5.23
    //        
    //         �޸���ʷ����
    //        
    //---------------------------------------------------------------------------------------
    public void createNewParcel(MgPolygon geom, ParcelProperty newParcel)
    {
        MgPropertyCollection properties = buildPropertyCol(newParcel);
        MgAgfReaderWriter agfWriter = new MgAgfReaderWriter();
        MgByteReader byteReader = agfWriter.Write(geom);
        properties.Add(new MgGeometryProperty("SHPGEOM", byteReader));

        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
        MgResourceIdentifier parcelSource = new MgResourceIdentifier("Library://MgTutorial/Data/Parcels.FeatureSource");

        MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
        commands.Add(new MgInsertFeatures("Parcels", properties));
        featureService.UpdateFeatures(parcelSource, commands, false);

        //////////////////////////////////////////
        /*
        MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
        MgPropertyCollection properties = new MgPropertyCollection();
        MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
        MgByteReader   byteReader = agfReaderWriter.Write(geometry);
        MgGeometryProperty geometryProperty = new MgGeometryProperty("SHPGEOM",byteReader);
        properties.Add(new MgInt32Property("RSQFT", 322));
        properties.Add(new MgStringProperty("RNAME", "YourName"));
        properties.Add(new MgStringProperty("RTYPE", "GFC"));

        MgPropertyCollection properties = new MgPropertyCollection ();
        properties.Add(geometryProperty);
        MgInsertFeatures insertCommand = new MgInsertFeatures(className, properties);
        commands.Add(insertCommand);
        featureService.UpdateFeatures(featureSource, commands, false);
         * */
    }
Beispiel #5
0
    //---------------------------------------------------------------------------------------
    //
    //        ���ܣ�����Ҫ�����ݣ������ڹ�����¼
    //
    //         ���ߣ�
    //
    //         ���ڣ� 2007.5.23
    //        
    //         �޸���ʷ����
    //        
    //---------------------------------------------------------------------------------------
    private MgPropertyCollection populateParcelFeatureAttributes(MgPolygon geom, ParcelProperty newParcel)
    {
        MgPropertyCollection props = new MgPropertyCollection();
        MgAgfReaderWriter agfWriter = new MgAgfReaderWriter();
        props.Add(new MgGeometryProperty("GEOM", agfWriter.Write(geom)));
        props.Add(new MgStringProperty("ACRE", newParcel.Acreage));
        props.Add(new MgStringProperty("BILLADDR", newParcel.BillingAddr));
        props.Add(new MgStringProperty("DESC1", newParcel.Description1));
        props.Add(new MgStringProperty("DESC2", newParcel.Description2));
        props.Add(new MgStringProperty("DESC3", newParcel.Description3));
        props.Add(new MgStringProperty("DESC4", newParcel.Description4));
        props.Add(new MgStringProperty("LOTDIM", newParcel.LotDimension));
        props.Add(new MgInt32Property("SQFT", newParcel.LotSize));
        props.Add(new MgStringProperty("OWNER", newParcel.Owner));
        props.Add(new MgStringProperty("ZONE", newParcel.Zoning));

        return props;
    }
Beispiel #6
0
    //---------------------------------------------------------------------------------------
    //
    //        ���ܣ�����һ����ΪtempParcel����ʱ��
    //
    //         ���ߣ�
    //
    //         ���ڣ� 2007.5.23
    //        
    //         �޸���ʷ����
    //        
    //---------------------------------------------------------------------------------------
    public void createTempParcels(MgPolygon geom, ParcelProperty newParcel, string sessionId)
    {
        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
        MgResourceService resService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);

        // ��ȡ��ͼ����
        MgMap map = new MgMap();
        map.Open(resService, "Sheboygan");
        // ������ʱ��
           MgResourceIdentifier tempLayerSourceId = new MgResourceIdentifier("Session:" + sessionId + "//tempParcel.FeatureSource");

        MgLayer tempParcelLayer = getLayerByName(map, "TempParcels");
        if (tempParcelLayer == null)
        {
            createTempParcelFeatureSource(featureService, tempLayerSourceId);
            tempParcelLayer = createTempParcelLayer(resService, tempLayerSourceId, sessionId);
            map.GetLayers().Insert(0, tempParcelLayer);
        }

        //��Ҫ��Դ�в���Ҫ������
        MgPropertyCollection props = populateParcelFeatureAttributes(geom, newParcel);
        MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
        commands.Add(new MgInsertFeatures("tempParcel", props));
        featureService.UpdateFeatures(tempLayerSourceId, commands, false);

        tempParcelLayer.SetVisible(true);
        tempParcelLayer.ForceRefresh();
        map.Save(resService);
    }