Beispiel #1
0
        private static List <Feature> getAllFeatures()
        {
            //Utilizes the get rectangle function to query the top left most point all the way to
            //the bottom right most point.  This gets all of the points.
            Point newPoint_tl = new geospatial.thrift.Point();

            newPoint_tl.X = -180;
            newPoint_tl.Y = 180;
            Point newPoint_br = new Point();

            newPoint_br.X = 180;
            newPoint_br.Y = -180;
            Rectangle rect = new Rectangle();

            rect.Top_lt = newPoint_tl;
            rect.Btm_rt = newPoint_br;
            List <Feature> features = client.getFeaturesInRect(rect);

            return(features);
        }
Beispiel #2
0
        private static void perform(geospatial.thrift.Geospatial.Client client)
        {
            //Scanner reader = new Scanner(System.in);
            bool loop = true;

            while (loop)
            {
                changeFeature();
                printOptions();
                int input = Convert.ToInt32(Console.ReadLine());
                switch (input)
                {
                case 1:
                    //Create a new feature
                    System.Console.Write("Enter the new point x: ");
                    double x = Convert.ToDouble(System.Console.ReadLine());
                    System.Console.Write("Enter the new point y: ");
                    double y        = Convert.ToDouble(System.Console.ReadLine());
                    Point  newPoint = new Point();
                    newPoint.X = x;
                    newPoint.Y = y;
                    System.Console.Write("Enter the new payload: ");
                    String newPayload = System.Console.ReadLine();
                    currentFeature = client.createFeature(newPoint, newPayload);
                    System.Console.WriteLine("Your new feature is now your current feature: " + currentFeature.Id);
                    break;

                case 2:
                    //Get a feature based on id
                    System.Console.WriteLine("Enter the feature id: ");
                    String id = System.Console.ReadLine();
                    currentFeature = client.getFeature(id);
                    if (currentFeature != null)
                    {
                        System.Console.WriteLine("Your current feature is now saved: " + currentFeature.Id);
                    }
                    else
                    {
                        System.Console.WriteLine("That feature does not exist.");
                    }
                    break;

                case 3:
                    //Get features in a rectangle based on 2 points
                    System.Console.WriteLine("Enter the top left x: ");
                    double x1 = Convert.ToDouble(System.Console.ReadLine());
                    System.Console.WriteLine("Enter the top left y: ");
                    double y1 = Convert.ToDouble(System.Console.ReadLine());
                    System.Console.WriteLine("Enter the bottom right x: ");
                    double x2 = Convert.ToDouble(System.Console.ReadLine());
                    System.Console.WriteLine("Enter the bottom right y: ");
                    double y2 = Convert.ToDouble(System.Console.ReadLine());
                    //reader.nextLine();
                    Point newPoint_tl = new geospatial.thrift.Point();
                    newPoint_tl.X = x1;
                    newPoint_tl.Y = y1;
                    Point newPoint_br = new Point();
                    newPoint_br.X = x2;
                    newPoint_br.Y = y2;
                    Rectangle rect = new Rectangle();
                    rect.Top_lt = newPoint_tl;
                    rect.Btm_rt = newPoint_br;
                    List <Feature> features = client.getFeaturesInRect(rect);
                    currentFeature = selectFeature(features);
                    break;

                case 4:
                    //Update the current feature in the database
                    if (currentFeature != null)
                    {
                        bool success = client.saveFeature(currentFeature);
                        if (success)
                        {
                            System.Console.WriteLine("Your feature was updated successfully.");
                        }
                        else
                        {
                            System.Console.WriteLine("You must have a non-null feature to update.");
                        }
                    }


                    break;

                case 5:
                    //Delete the current feature
                    bool deleteSuccess = client.deleteFeature(currentFeature);
                    if (deleteSuccess)
                    {
                        System.Console.WriteLine("Your feature was deleted successfully.");
                    }
                    else
                    {
                        System.Console.WriteLine("Your feature was deleted unsuccessfully.");
                    }
                    break;

                case 6:
                    //Change the current feature's properties
                    if (currentFeature == null)
                    {
                        System.Console.WriteLine("You must have a non-null feature to change.");
                        break;
                    }
                    bool changeFeatureLoop = true;
                    while (changeFeatureLoop)
                    {
                        printFeatureChangeOptions();
                        int option = Convert.ToInt32(System.Console.ReadLine());
                        //reader.nextLine();
                        switch (option)
                        {
                        case 1:
                            //Change the point of the feature
                            System.Console.Write("Enter the new point x: ");
                            double newX = Convert.ToDouble(System.Console.ReadLine());
                            System.Console.Write("Enter the new point y: ");
                            double newY = Convert.ToDouble(System.Console.ReadLine());
                            newPoint             = new geospatial.thrift.Point();
                            newPoint.X           = newX;
                            newPoint.Y           = newY;
                            currentFeature.Point = newPoint;
                            client.saveFeature(currentFeature);
                            break;

                        case 2:
                            //Change the state of the feature
                            System.Console.Write("Enter the new state (1 for clean or 2 for dirty): ");
                            int newState = Convert.ToInt32(System.Console.ReadLine());

                            if (newState == 1)
                            {
                                currentFeature.State = FeatureState.CLEAN;
                            }
                            else if (newState == 2)
                            {
                                currentFeature.State = FeatureState.DIRTY;
                            }
                            else
                            {
                                System.Console.WriteLine("Please enter a valid state.");
                            }
                            client.saveFeature(currentFeature);
                            break;

                        case 3:
                            //Change the payload of the feature
                            System.Console.Write("Enter the new payload: ");
                            newPayload             = System.Console.ReadLine();
                            currentFeature.Payload = newPayload;
                            client.saveFeature(currentFeature);

                            break;

                        case 4:
                            //Break loop
                            changeFeatureLoop = false;
                            break;

                        default:
                            System.Console.WriteLine("Enter a valid option.");
                            break;
                        }
                    }
                    break;

                case 7:
                    //Break loop
                    loop = false;
                    break;

                default:
                    System.Console.WriteLine("Please enter a valid option.");
                    break;
                }
                //System.Console.Write("Would you like to change the feature you are editing?");
            }
        }