Beispiel #1
0
        // Return true if the specified layer may be set to Editable.
        // In the case of remote data, we may find that the Geocolumn is readonly,
        // there is a spatial schema which provides for the ability to create a point
        // geometry by referencing a geometry in another table. In this case, the table
        // may be editable but the geometry column will be marked as readonly.
        // Also Seamless tables can't be edited.
        private bool LayerCanBeMadeEditable(FeatureLayer layer)
        {
            bool b = false;

            if (layer.Table.TableInfo.TableType == TableType.Seamless)
            {
                b = false;                 // can't edit seamless tables
            }
            else if (_editFilter != null && _editFilter is ToolFilter)
            {
                // The filter allows us to change Editable status;
                // now see if the table also allows us.
                if (layer.Table.SessionInfo.ReadOnly == false)
                {
                    // Table isn't read only, so we can proceed.
                    // If geocolumn isn't read only, the layer can be made editable.
                    GeometryColumn geoCol  = null;
                    Columns        columns = layer.Table.TableInfo.Columns;
                    foreach (Column col in columns)
                    {
                        geoCol = col as GeometryColumn;
                        if (geoCol != null)
                        {
                            break;
                        }
                    }
                    if (geoCol != null && geoCol.ReadOnly == false)
                    {
                        b = true;
                    }
                }
            }
            return(b);
        }
Beispiel #2
0
 public override void WriteLayerProperties(System.Xml.XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteAttributeString("TimeSeries", TimeSeries.ToString());
     xmlWriter.WriteAttributeString("BeginRange", BeginRange.ToString());
     xmlWriter.WriteAttributeString("EndRange", EndRange.ToString());
     xmlWriter.WriteAttributeString("Decay", Decay.ToString());
     xmlWriter.WriteAttributeString("CoordinatesType", CoordinatesType.ToString());
     xmlWriter.WriteAttributeString("LatColumn", LatColumn.ToString());
     xmlWriter.WriteAttributeString("LngColumn", LngColumn.ToString());
     xmlWriter.WriteAttributeString("GeometryColumn", GeometryColumn.ToString());
     xmlWriter.WriteAttributeString("AltType", AltType.ToString());
     xmlWriter.WriteAttributeString("MarkerMix", MarkerMix.ToString());
     xmlWriter.WriteAttributeString("ColorMap", ColorMap.ToString());
     xmlWriter.WriteAttributeString("MarkerColumn", MarkerColumn.ToString());
     xmlWriter.WriteAttributeString("ColorMapColumn", ColorMapColumn.ToString());
     xmlWriter.WriteAttributeString("PlotType", PlotType.ToString());
     xmlWriter.WriteAttributeString("MarkerIndex", MarkerIndex.ToString());
     xmlWriter.WriteAttributeString("MarkerScale", MarkerScale.ToString());
     xmlWriter.WriteAttributeString("AltUnit", AltUnit.ToString());
     xmlWriter.WriteAttributeString("AltColumn", AltColumn.ToString());
     xmlWriter.WriteAttributeString("StartDateColumn", StartDateColumn.ToString());
     xmlWriter.WriteAttributeString("EndDateColumn", EndDateColumn.ToString());
     xmlWriter.WriteAttributeString("SizeColumn", SizeColumn.ToString());
     xmlWriter.WriteAttributeString("HyperlinkFormat", HyperlinkFormat.ToString());
     xmlWriter.WriteAttributeString("HyperlinkColumn", HyperlinkColumn.ToString());
     xmlWriter.WriteAttributeString("ScaleFactor", ScaleFactor.ToString());
     xmlWriter.WriteAttributeString("PointScaleType", PointScaleType.ToString());
     xmlWriter.WriteAttributeString("ShowFarSide", ShowFarSide.ToString());
     xmlWriter.WriteAttributeString("RaUnits", RaUnits.ToString());
     xmlWriter.WriteAttributeString("HoverTextColumn", NameColumn.ToString());
     xmlWriter.WriteAttributeString("XAxisColumn", XAxisColumn.ToString());
     xmlWriter.WriteAttributeString("XAxisReverse", XAxisReverse.ToString());
     xmlWriter.WriteAttributeString("YAxisColumn", YAxisColumn.ToString());
     xmlWriter.WriteAttributeString("YAxisReverse", YAxisReverse.ToString());
     xmlWriter.WriteAttributeString("ZAxisColumn", ZAxisColumn.ToString());
     xmlWriter.WriteAttributeString("ZAxisReverse", ZAxisReverse.ToString());
     xmlWriter.WriteAttributeString("CartesianScale", CartesianScale.ToString());
     xmlWriter.WriteAttributeString("CartesianCustomScale", CartesianCustomScale.ToString());
     xmlWriter.WriteAttributeString("DynamicData", DynamicData.ToString());
     xmlWriter.WriteAttributeString("AutoUpdate", AutoUpdate.ToString());
     xmlWriter.WriteAttributeString("DataSourceUrl", DataSourceUrl.ToString());
 }
Beispiel #3
0
        private void loadEagleLayer()
        {
            //初始化鹰眼图层 用户画框

            TableInfoMemTable ti = new TableInfoMemTable("EagleEyeTemp");

            ti.Temporary = true;
            Column column;

            column          = new GeometryColumn(mapControl2.Map.GetDisplayCoordSys());
            column.Alias    = "MI_Geometry ";
            column.DataType = MIDbType.FeatureGeometry;
            ti.Columns.Add(column);

            column          = new Column();
            column.Alias    = "MI_Style ";
            column.DataType = MIDbType.Style;
            ti.Columns.Add(column);
            Table table;

            try
            {
                table = Session.Current.Catalog.CreateTable(ti);
            }
            catch (Exception ex)
            {
                table = Session.Current.Catalog.GetTable("EagleEyeTemp");
            }
            if (mapControl2.Map.Layers["MyEagleEye"] != null)
            {
                mapControl2.Map.Layers.Remove(eagleEye);
            }
            eagleEye = new FeatureLayer(table, "EagleEye ", "MyEagleEye");
            mapControl2.Map.Layers.Insert(0, eagleEye);
            mapControl1.Refresh();
        }
Beispiel #4
0
        private void showPointOnSearchTableMap(double x, double y)
        {
            MapInfo.Mapping.Map          map         = Session.Current.MapFactory.CreateEmptyMap(System.IntPtr.Zero, new Size(10, 10));
            MapInfo.Mapping.FeatureLayer searchLayer = new MapInfo.Mapping.FeatureLayer(_searchTable);
            map.Layers.Add(searchLayer);

            MapForm1 mapForm    = new MapForm1(map);
            Form     parentForm = this;

            // create a temp table and add a featurelayer for it (use map alias as table alias)
            // make the table hidden (maybe)
            MapInfo.Geometry.CoordSys coordSys = map.GetDisplayCoordSys();
            TableInfoMemTable         ti       = new TableInfoMemTable("temp");

            ti.Temporary = true;

            // add object column
            Column col;

            col          = new GeometryColumn(coordSys); // specify coordsys for object column
            col.Alias    = "obj";
            col.DataType = MIDbType.FeatureGeometry;
            ti.Columns.Add(col);

            // add style column
            col          = new Column();
            col.Alias    = "MI_Style";
            col.DataType = MIDbType.Style;
            ti.Columns.Add(col);

            Table pointTable = Session.Current.Catalog.CreateTable(ti);

            // I am using a Point example here. You can create a rectangle instead
            MapInfo.Geometry.FeatureGeometry      g  = new MapInfo.Geometry.Point(coordSys, x, y);
            MapInfo.Styles.SimpleVectorPointStyle vs = new MapInfo.Styles.SimpleVectorPointStyle(37, System.Drawing.Color.Red, 14);
            MapInfo.Styles.CompositeStyle         cs = new MapInfo.Styles.CompositeStyle(vs);

            MICommand cmd = _miConnection.CreateCommand();

            cmd.Parameters.Add("geometry", MIDbType.FeatureGeometry);
            cmd.Parameters.Add("style", MIDbType.Style);
            cmd.CommandText = "Insert Into temp (obj,MI_Style) values (geometry,style)";
            cmd.Prepare();
            cmd.Parameters[0].Value = g;
            cmd.Parameters[1].Value = cs;
            int nchanged = cmd.ExecuteNonQuery();

            cmd.Dispose();

            map.Layers.Add(new MapInfo.Mapping.FeatureLayer(pointTable));
            // another way: Map.Load(new MapTableLoader(table));

            // make the map encompass the entire search layer
            map.SetView(searchLayer);

            // size the map form
            mapForm.Size = new Size(500, 500);

            //Show the form like a dialog (modal)
            mapForm.ShowDialog(parentForm);

            pointTable.Close();
        }
        private void showPointOnSearchTableMap(double x, double y)
        {
            MapInfo.Mapping.Map map = Session.Current.MapFactory.CreateEmptyMap(System.IntPtr.Zero, new Size(10, 10));
            MapInfo.Mapping.FeatureLayer searchLayer = new MapInfo.Mapping.FeatureLayer(_searchTable);
            map.Layers.Add(searchLayer);

            MapForm1 mapForm = new MapForm1(map);
            Form parentForm = this;

            // create a temp table and add a featurelayer for it (use map alias as table alias)
            // make the table hidden (maybe)
            MapInfo.Geometry.CoordSys coordSys = map.GetDisplayCoordSys();
            TableInfoMemTable ti = new TableInfoMemTable("temp");
            ti.Temporary = true;

            // add object column
            Column col;
            col = new GeometryColumn(coordSys); // specify coordsys for object column
            col.Alias = "obj";
            col.DataType = MIDbType.FeatureGeometry;
            ti.Columns.Add(col);

            // add style column
            col = new Column();
            col.Alias = "MI_Style";
            col.DataType = MIDbType.Style;
            ti.Columns.Add(col);

            Table pointTable = Session.Current.Catalog.CreateTable(ti);

            // I am using a Point example here. You can create a rectangle instead
            MapInfo.Geometry.FeatureGeometry g = new MapInfo.Geometry.Point(coordSys, x, y);
            MapInfo.Styles.SimpleVectorPointStyle vs = new MapInfo.Styles.SimpleVectorPointStyle(37, System.Drawing.Color.Red, 14);
            MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(vs);

            MICommand cmd = _miConnection.CreateCommand();
            cmd.Parameters.Add("geometry", MIDbType.FeatureGeometry);
            cmd.Parameters.Add("style", MIDbType.Style);
            cmd.CommandText = "Insert Into temp (obj,MI_Style) values (geometry,style)";
            cmd.Prepare();
            cmd.Parameters[0].Value = g;
            cmd.Parameters[1].Value = cs;
            int nchanged = cmd.ExecuteNonQuery();
            cmd.Dispose();

            map.Layers.Add(new MapInfo.Mapping.FeatureLayer(pointTable));
            // another way: Map.Load(new MapTableLoader(table));

            // make the map encompass the entire search layer
            map.SetView(searchLayer);

            // size the map form
            mapForm.Size = new Size(500, 500);

            //Show the form like a dialog (modal)
            mapForm.ShowDialog(parentForm);

            pointTable.Close();
        }
Beispiel #6
0
        private XmlElement CreateFeatureLayerElement(XmlDocument _doc, IMapLayer layer, string uniqueID)
        {
            Map                   map           = GetMapObj(_mapAlias);
            FeatureLayer          flayer        = (FeatureLayer)layer;
            bool                  bRasterLayer  = false;
            bool                  bHasModifiers = false;
            FeatureStyleModifiers mods          = flayer.Modifiers;

            if (mods.Count > 0)
            {
                bHasModifiers = true;
            }
            if (flayer.Type == LayerType.Raster ||
                flayer.Type == LayerType.Grid ||
                flayer.Type == LayerType.Wms)
            {
                bRasterLayer = true;
            }
            XmlElement element = _doc.CreateElement("branch");

            if (bHasModifiers)
            {
                element.SetAttribute("branchtype", "", "folder");
                element.SetAttribute("expanded", null, "true");
            }
            else
            {
                element.SetAttribute("branchtype", "", "leaf");
            }
            element.SetAttribute("title", null, layer.Name);
            element.SetAttribute("alias", "", layer.Alias);
            element.SetAttribute("type", "", layer.Type.ToString());
            element.SetAttribute("uniqueid", "", uniqueID);
            if (bRasterLayer)
            {
                element.SetAttribute("code", "", "nonselectable");
            }
            else if (bHasModifiers)
            {
                element.SetAttribute("code", "", "4");
            }
            else
            {
                element.SetAttribute("code", "", "featurelayer");
            }

            if (layer.IsVisible)
            {
                element.SetAttribute("visible", "true");
            }
            else
            {
                element.SetAttribute("visible", "false");
                if (flayer.VisibleRangeEnabled && !flayer.VisibleRange.Within(map.Zoom))
                {
                    element.SetAttribute("rangevisible", "true");
                }
                else
                {
                    element.SetAttribute("rangevisible", "false");
                }
            }

            // If layer is remote, image can be set from database style
            // null value returned if layer is not remote
            string image = DetermineRemoteGeomType(flayer);

            if (image == null)
            {
                image = "lclayerpoint.bmp";
                if (bRasterLayer)
                {
                    image = "lclayerraster.bmp";
                }
                else
                {
                    TableInfo      tableInfo = flayer.Table.TableInfo;
                    GeometryColumn geoCol    = null;
                    Columns        columns   = tableInfo.Columns;
                    foreach (Column col in columns)
                    {
                        geoCol = col as GeometryColumn;
                        if (geoCol != null)
                        {
                            break;
                            // TODO: Check for the case where there are MULTIPLE columns.
                        }
                    }
                    if (geoCol != null)
                    {
                        if (geoCol.PredominantGeometryType == GeometryType.MultiCurve)
                        {
                            image = "lclayerline.bmp";
                        }
                        else if ((geoCol.PredominantGeometryType == GeometryType.MultiPolygon) ||
                                 (geoCol.PredominantGeometryType == GeometryType.Rectangle))
                        {
                            image = "lclayerregion.bmp";
                        }
                        else if (geoCol.PredominantGeometryType == GeometryType.Point)
                        {
                            image = "lclayerpoint.bmp";
                        }
                    }
                }
            }
            element.SetAttribute("img", null, image);

            if (bHasModifiers)
            {
                CreateFeatureModifierElement(_doc, flayer, element, uniqueID);
            }
            return(element);
        }
Beispiel #7
0
        /// <summary>
        /// Process a csv file, mining the columns for something that we recognise as an area key. If this is satisfied, then we pass the file on to the next procedure
        /// to make maps from the columns given the area key we found here.
        /// </summary>
        /// <param name="CSVUri"></param>
        /// <param name="UniqueKey">Key unique to the table and data file i.e. not column unique</param>
        /// <param name="Title"></param>
        private void ProcessFile(Uri CSVUri, string UniqueKey, string Title)
        {
            //First, the area geometry
            try
            {
                GF.DataRowsToCheck = 200;
                GeometryProbabilities probs = GF.ProbableGeometryFromDataFile(CSVUri);
                string GeometryName;
                int    ColumnIndex;
                float  prob;
                bool   success = probs.GetMax(out GeometryName, out ColumnIndex, out prob);
                if (success)
                {
                    //This is all the geometries that made the threshold
                    var sorted_probs = probs.OrderByDescending(p => p.Value); //sort matched columns by probability values
                    if ((sorted_probs.Count() > 1) && ((sorted_probs.ElementAt(0).Value - sorted_probs.ElementAt(1).Value) <= float.Epsilon))
                    {
                        Console.WriteLine("Area geometry tie - using geom hints");
                        //We have a tie, so use the geometry hints for additional weighting.
                        //Need to create a new GeometryProbabilites object
                        GeometryProbabilities weighted_probs = new GeometryProbabilities();
                        foreach (KeyValuePair <GeometryColumn, float> KVP in probs)
                        {
                            GeometryColumn col = KVP.Key;
                            if (_GeomHints.ContainsKey(col.GeometryName))
                            {
                                col.Probability *= _GeomHints[col.GeometryName];
                            }
                            weighted_probs.Add(col.GeometryName, col.ColumnIndex, col.ColumnName, col.Probability);
                        }
                        //now switch old probs and new weighted ones
                        probs = weighted_probs;
                        //and then do a re-sort
                        sorted_probs = probs.OrderByDescending(p => p.Value);
                    }
                    foreach (KeyValuePair <GeometryColumn, float> p in sorted_probs)
                    {
                        Console.WriteLine("Area Geometry: " + p.Key.GeometryName + " Column=" + p.Key.ColumnIndex + " probability=" + p.Key.Probability);
                    }
                    probs.GetMax(out GeometryName, out ColumnIndex, out prob);
                    if (prob > 0.8)
                    {
                        MakeMapsFromColumns(CSVUri, UniqueKey, GeometryName, ColumnIndex, Title);
                    }
                }

                //Second, try a point geometry
                //PointGeometryXYCRS PXYCRS = GF.ProbablePointGeometryFromDataFile(CSVUri);
                //if (!string.IsNullOrEmpty(PXYCRS.XFieldName))
                //{
                //    Console.WriteLine("Point Geometry: XField=" + PXYCRS.XFieldName + " YField=" + PXYCRS.YFieldName);
                //    //write out CRS?
                //}
                ////write out the column type information gained from the point data analysis
                //foreach (ColumnType col in GF.ProbablePointDataColumnTypes)
                //{
                //    Console.Write(col.Name);
                //    if (col.IsIndex)
                //    {
                //        Console.Write(" (Index)");
                //    }
                //    else if (col.IsNumeric)
                //    {
                //        Console.Write(" Numeric Min=" + col.Min + " Max=" + col.Max);
                //    }
                //    Console.WriteLine();
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }
        }