Exemple #1
0
        public override bool Equals(object obj)
        {
            GCS_WCS84 other = obj as GCS_WCS84;

            if (other == null)
            {
                return(false);
            }
            return(other.GetHashCode() == GetHashCode() || other == this);
        }
Exemple #2
0
        public List <GCS_WCS84> ConvertCoordinates(List <GCS_HK1980> original)
        {
            // "Circularly" tells each dialer to handle a conversion.

            // First initialize results; results should be empty;
            List <GCS_WCS84> results = new List <GCS_WCS84>(original.Count);

            for (int i = 0; i < original.Count; i++)
            {
                results.Add(null);
            }
            //Console.WriteLine("Generated result-list with count " + results.Count);

            // Then initialize mapper
            Dictionary <ConverterDialer, int> dialerMapping = new Dictionary <ConverterDialer, int>();

            // Then sets up variables
            int fromIndex              = 0;
            int loopingIndex           = 0;
            int completedRequestsCount = 0;

            while (true)
            {
                ConverterDialer currentDialer = dialers[loopingIndex];

                // Optimized: first retrieve the result, and then dial it.
                if (currentDialer.IsDone)
                {
                    // Retrieve result
                    GCS_WCS84 result = currentDialer.RetrieveResult();
                    // Store the result properly
                    results[dialerMapping[currentDialer]] = result;

                    //Console.WriteLine("Copying result from dialer #" + loopingIndex + " back to request #" + dialerMapping[currentDialer]);

                    // See if we can break
                    completedRequestsCount++;
                    if (completedRequestsCount == original.Count)
                    {
                        // All completed. Break;
                        break;
                    }
                }
                if (currentDialer.IsReady)
                {
                    // Check if we have anything left to be converted
                    if (fromIndex < original.Count)
                    {
                        // We still have entries to convert.

                        // Inject parameter and let it spin
                        currentDialer.DialForConversion(original[fromIndex]);
                        // Write down the mapping
                        dialerMapping[currentDialer] = fromIndex;

                        //Console.WriteLine("Dialing dialer #" + loopingIndex + " with request #" + fromIndex);

                        fromIndex++;
                    }
                }

                // Move to next index and wait a bit
                loopingIndex = (loopingIndex + 1) % dialers.Count;
                cumulativeRequests++;
                if (cumulativeRequests > requestFrequency)
                {
                    cumulativeRequests = 0;
                    Console.WriteLine("Processing " + completedRequestsCount + " of " + original.Count + ".");
                }
                //Console.WriteLine("Moving to dialer #" + loopingIndex);
                Thread.Sleep(requestDelay);
            }

            // Should be all done.
            Console.WriteLine("Processed " + original.Count + " of " + original.Count + ".");
            return(results);
        }