Exemple #1
0
        private IEnumerable <trout_stream_section> CreateSection(trout_streams_minnesota asdf, StreamRoute route)
        {
            var routeMultilineString      = route.OriginalGeometry as IMultiLineString;
            var troutStreamSection        = (asdf.OriginalGeometry as IMultiLineString);
            var desiredTroutStreamSection = (asdf.Geometry_4326 as IMultiLineString);
            var TroutStreamSection4236    = (asdf.Geometry_4326 as IMultiLineString);
            var numberOfGeometries        = troutStreamSection.Geometries.Count();

            for (var i = 0; i < numberOfGeometries; i++)
            {
                var s = troutStreamSection.Geometries[i] as ILineString;
                var desiredGeometry = desiredTroutStreamSection.Geometries[i] as ILineString;
                desiredGeometry.SRID = 44326;
                var asdf4236 = TroutStreamSection4236.Geometries[i];

                var trout_section = new trout_stream_section();

                var centroid = asdf4236.Centroid;
                trout_section.centroid_latitude  = Convert.ToDecimal(centroid.X);
                trout_section.centroid_longitude = Convert.ToDecimal(centroid.Y);
                trout_section.length_mi          = Convert.ToDecimal(s.Length) / METERS_IN_MILE;
                trout_section.public_length      = 0;
                trout_section.section_name       = asdf.kittle_nam ?? "Unnamed Stream";
                trout_section.source_id          = asdf.kittle_nbr;

                var multilineString = new MultiLineString(new[] { s });

                var t         = new LinearReference();
                var wktWriter = new WKTWriter();
                wktWriter.EmitSRID   = true;
                wktWriter.HandleSRID = true;
                var desiredMultilineString = new MultiLineString(new[] { desiredGeometry });
                desiredMultilineString.SRID = 4326;
                var text = wktWriter.Write(desiredMultilineString);
//                var superResultLol =
                var writer = new WKBWriter();
//                writer.HandleSRID = true;
//                writer.EmitSRID = true;

                var binResult = writer.Write(desiredMultilineString);
                var bin2      = desiredMultilineString.ToBinary();

                var stringResult = System.Text.Encoding.UTF7.GetString(binResult);
                trout_section.Geom = asdf.Geom_4326;
                var result = t.GetIntersectionOfLine(routeMultilineString.Geometries.First() as ILineString, s).ToList();

                trout_section.start = (decimal)result[0] / METERS_IN_MILE;
                trout_section.stop  = (decimal)result[1] / METERS_IN_MILE;

                yield return(trout_section);
            }
        }
        private IEnumerable <trout_stream_section> CreateSection(trout_streams_minnesota asdf, StreamRoute route)
        {
            var routeMultilineString      = route.OriginalGeometry as IMultiLineString;
            var troutStreamSection        = (asdf.OriginalGeometry as IMultiLineString);
            var desiredTroutStreamSection = (asdf.Geometry_4326 as IMultiLineString);
            var TroutStreamSection4236    = (asdf.Geometry_4326 as IMultiLineString);
            var numberOfGeometries        = troutStreamSection.Geometries.Count();

            for (var i = 0; i < numberOfGeometries; i++)
            {
                var s = troutStreamSection.Geometries[i] as ILineString;
                var desiredGeometry = desiredTroutStreamSection.Geometries[i];
                var asdf4236        = TroutStreamSection4236.Geometries[i];

                var trout_section = new trout_stream_section();

                var centroid = asdf4236.Centroid;
                trout_section.centroid_latitude  = Convert.ToDecimal(centroid.X);
                trout_section.centroid_longitude = Convert.ToDecimal(centroid.Y);
                trout_section.length_mi          = Convert.ToDecimal(s.Length) / 1609.3440M;
                trout_section.public_length      = 0;
                trout_section.section_name       = asdf.kittle_nam ?? "Unnamed Stream";
                trout_section.source_id          = asdf.kittle_nbr;

                var multilineString = new MultiLineString(new[] { s });

                var t    = new LinearReference();
                var text = desiredGeometry.AsText();
                var bin  = multilineString.AsBinary();

                trout_section.Geom = text;//asdf.Geom_3857;

                var result = t.GetIntersectionOfLine(routeMultilineString.Geometries.First() as ILineString, s).ToList();

                trout_section.start = (decimal)result[0];
                trout_section.stop  = (decimal)result[1];

                yield return(trout_section);
            }
        }