예제 #1
0
        // -----------------------------------------------------------------------------------------------
        // iterates over the line between the coordinates start->end, stepping by degreesBetweenSlices, and
        // generating a slice descriptor at each step that goes from current location to current location + sliceDelta
        private List<SliceDescriptor> generateSliceDescriptors( Tuple<double,double> start, Tuple<double,double> end, 
                                                                double degreesBetweenSlices,
                                                                Tuple<double,double> sliceDelta )
        {
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Reset();
            stopwatch.Start();

            // determine how many slices will be generated
            var startEndDelta = Vector.Ops.Delta( start, end );

            // length of delta
            double startEndDeltaDegrees = Vector.Ops.Length( startEndDelta );

            // note : add 1 because the division determines the count of spaces -between- slices
            int numSlices = (int)(startEndDeltaDegrees / degreesBetweenSlices) + 1;

            var slices = new List<SliceDescriptor>( numSlices );

            // need normalized length start->end delta
            var normalizedStartEndDelta = Vector.Ops.Normalize( startEndDelta );

            // now need coincident vector, but sized to degrees step
            var deltaStep = Vector.Ops.Scale( normalizedStartEndDelta, degreesBetweenSlices );

            // starting point of current slice
            double currentStartLatitude = start.Item1;
            double currentStartLongitude = start.Item2;

            for ( int currentSliceIndex = 0; currentSliceIndex < numSlices; ++currentSliceIndex )
            {
                var slice = new SliceDescriptor();

                // -- generate coordinates --
                slice.Start = new Tuple<double, double>( currentStartLatitude, currentStartLongitude );
                slice.End = new Tuple<double,double>( currentStartLatitude + sliceDelta.Latitude(), currentStartLongitude + sliceDelta.Longitude());

                // -- generate filename --
                slice.filename = generateSliceFilename( slice, currentSliceIndex, _appendCoordinatesToFilenames );

                slices.Add( slice );

                currentStartLatitude += deltaStep.Latitude();
                currentStartLongitude += deltaStep.Longitude();
            }

            stopwatch.Stop();
            addTiming( "generate slice descriptors", stopwatch.ElapsedMilliseconds );

            return slices;
        }
예제 #2
0
 // ------------------------------------------------------------------------------------------------
 private Tuple<int, int> CoordinateToRowCol( Tuple<double,double> coordinate )
 {
     return new Tuple<int,int>( _data.Descriptor.LatitudeToRowIndex( coordinate.Latitude() ), _data.Descriptor.LongitudeToColumnIndex( coordinate.Longitude() ) );
 }