Example #1
0
        //This is the full GPX 1.1 schema.
        //Option 1 - Add all schema defined fields, even if they are not used
        //TODO - Option 2 - Scan file and only use fields used in this file.
        //var search = Root.Descendants(_ns + type.Path);
        private IFields BuildFields(GpxFeatureClass featureClass)
        {
            var description = new FeatureClassDescriptionClass();
            var fields = (IFieldsEdit)description.RequiredFields;
            IFieldEdit field = new FieldClass();

            //Geometry
            var geometryIndex = fields.FindField(description.ShapeFieldName);
            var geometry = (IGeometryDefEdit)fields.Field[geometryIndex].GeometryDef;
            geometry.GeometryType_2 = featureClass.GeometryType;
            geometry.SpatialReference_2 = SpatialReference;
            geometry.HasM_2 = false;
            geometry.HasZ_2 = true;  //FIXME - this may be false.

            //Common Fields
            field.Name_2 = "name";
            field.AliasName_2 = "Name";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            // ReSharper disable UseObjectOrCollectionInitializer
            //These COM classes do not support object initializers
            field = new FieldClass();
            field.Name_2 = "cmt";
            field.AliasName_2 = "Comment";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            field = new FieldClass();
            field.Name_2 = "desc";
            field.AliasName_2 = "Description";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            field = new FieldClass();
            field.Name_2 = "src";
            field.AliasName_2 = "Source";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            field = new FieldClass();
            field.Name_2 = "link";
            field.AliasName_2 = "Hyperlink";
            //field.Type_2 = esriFieldType.esriFieldTypeXML;
            //XML datatype is not fully supported in Desktop (i.e. no value is displayed, and export to shapefile will fail)
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            //GPX 1.0
            field = new FieldClass();
            field.Name_2 = "url";
            field.AliasName_2 = "Url link";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            //GPX 1.0
            field = new FieldClass();
            field.Name_2 = "urlname";
            field.AliasName_2 = "Url Name";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            field = new FieldClass();
            field.Name_2 = "type";
            field.AliasName_2 = "Type";
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            field = new FieldClass();
            field.Name_2 = "extensions";
            //field.Type_2 = esriFieldType.esriFieldTypeXML;
            field.Type_2 = esriFieldType.esriFieldTypeString;
            fields.AddField(field);

            //Only for Routes and Tracks
            if (featureClass.Path == "rte" || featureClass.Path == "trk")
            {
                field = new FieldClass();
                field.Name_2 = "number";
                field.AliasName_2 = featureClass.Path == "rte" ? "Route Number" : "Track Number";
                field.Type_2 = esriFieldType.esriFieldTypeInteger;
                fields.AddField(field);
            }

            //Only for Points
            if (featureClass.Path == "wpt" || featureClass.Path == "trkpt" || featureClass.Path == "rtept")
            {
                field = new FieldClass();
                field.Name_2 = "ele";
                field.AliasName_2 = "Elevation";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "time";
                field.AliasName_2 = "Time (UTC)";
                field.Type_2 = esriFieldType.esriFieldTypeDate;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "magvar";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "geoidheight";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "sym";
                field.AliasName_2 = "Symbol";
                field.Type_2 = esriFieldType.esriFieldTypeString;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "fix";
                field.AliasName_2 = "GpsFix";
                field.Type_2 = esriFieldType.esriFieldTypeString;
                field.Length_2 = 4;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "sat";
                field.AliasName_2 = "Satellites";
                field.Type_2 = esriFieldType.esriFieldTypeInteger;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "hdop";
                field.AliasName_2 = "HDOP";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "vdop";
                field.AliasName_2 = "VDOP";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "pdop";
                field.AliasName_2 = "PDOP";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "ageofdgpsdata";
                field.Type_2 = esriFieldType.esriFieldTypeDouble;
                fields.AddField(field);

                field = new FieldClass();
                field.Name_2 = "dgpsid";
                field.Type_2 = esriFieldType.esriFieldTypeInteger;
                fields.AddField(field);
                // ReSharper restore UseObjectOrCollectionInitializer
            }

            return fields;
        }
Example #2
0
        private IGeometry BuildWorkingGeometry(GpxFeatureClass featureClass)
        {
            IGeometry result = null;

            if (featureClass.GeometryType == esriGeometryType.esriGeometryPoint)
                result = new PointClass();
            if (featureClass.GeometryType == esriGeometryType.esriGeometryPolyline)
                result = new PolylineClass();
            if (featureClass.GeometryType == esriGeometryType.esriGeometryPolygon)
                result = new PolygonClass();

            if (result == null)
                throw new ArgumentException("Geometry type must be Point/Polyline/Polygon", "featureClass");

            result.SpatialReference = SpatialReference;
            return result;
        }
Example #3
0
 internal IEnumerator<XElement> GetEnumerator(GpxFeatureClass type)
 {
     return Root.Descendants().Where(e => e.Name == _xmlNamespace + type.Path).GetEnumerator();
 }