Ejemplo n.º 1
0
            /// <summary>
            /// CreateFeatures - make ESRI features based on text
            /// </summary>
            /// <param name="layername">layer to add data to</param>
            /// <returns></returns>
            internal bool CreateFeatures(string layername)
            {
                bool result = true;

                try
                {
                    ESRI.ArcGIS.Carto.IFeatureLayer2 featlayer = code.Layers.getFeatureLayerByName("MyLines");
                    if (featlayer != null)
                    {
                        ESRI.ArcGIS.Geodatabase.IFeatureBuffer newFeatBuff = featlayer.FeatureClass.CreateFeatureBuffer();

                        ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featlayer.FeatureClass.Insert(true);
                        foreach (TextGeomItem item in this.TextGeometries)
                        {
                            //        // ID = unique id for gis line feature
                            newFeatBuff.set_Value(featlayer.FeatureClass.FindField("LineID"), Guid.NewGuid().ToString("B"));
                            newFeatBuff.set_Value(featlayer.FeatureClass.FindField("LETTER"), item.Text);

                            newFeatBuff.Shape = item.Geometry;
                            featureCursor.InsertFeature(newFeatBuff);
                        }
                        featureCursor.Flush();
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
                    }
                    return(result);
                }
                catch (System.Exception ex)
                {
                    return(false);
                }
            }
Ejemplo n.º 2
0
 internal static ESRI.ArcGIS.Carto.IFeatureLayer2 getFeatureLayerByName(string name)
 {
     if (name.Length > 0)
     {
         ESRI.ArcGIS.Carto.ILayer layer = getLayerByName(name);
         if (layer != null)
         {
             ESRI.ArcGIS.Carto.IFeatureLayer2 featlayer = (ESRI.ArcGIS.Carto.IFeatureLayer2)layer;
             return(featlayer);
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            // for now map must be wgs84
            if (ArcMap.Document.FocusMap.SpatialReference == null)
            {
                MessageBox.Show("Please put Map Document Data Frame into - Geographic Coordinate System: WGS 1984");
                return;
            }
            if (ArcMap.Document.FocusMap.SpatialReference.FactoryCode != 4326)
            {
                MessageBox.Show("Please put Map Document Data Frame into - Geographic Coordinate System: WGS 1984");
                return;
            }


            // convert text
            if (txtText.Text.Length > 0)
            {
                // convert and collect text info
                code.TextGeomsStruct.TextGeomCollection tgCollection = new code.TextGeomsStruct.TextGeomCollection(txtText.Text);
                ESRI.ArcGIS.Carto.IFeatureLayer2        featLayer    = (ESRI.ArcGIS.Carto.IFeatureLayer2)code.Layers.getLayerByName("MyLines");
                if (featLayer == null)
                {
                    //  create new layer to hold features
                    code.CreateLineLayer createLineFeatureClass = new code.CreateLineLayer();
                    featLayer = createLineFeatureClass.CreateFeatureLayer("MyLines", code.Layers.returnSR(), "in_memory");
                    // featLayer = code.Layers.CreateFeatureLayer("MyLines", code.Layers.returnSR(), "in_memory");
                    ArcMap.Document.FocusMap.AddLayer((ESRI.ArcGIS.Carto.ILayer)featLayer);
                    // actually create the features and add them to the layer
                    bool b = tgCollection.CreateFeatures("MyLines");
                }
                else
                {
                    // TODO: this will cause stacked text if ran more then once. need to add parameter to shift new text
                    bool b = tgCollection.CreateFeatures("MyLines");
                }
                ArcMap.Document.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography, null, null);
            }
        }