Esempio n. 1
0
        public List <WayNodeModel> getPrimaryWayEdgeForScreenshots()
        {
            string query = "SELECT a.way_id, a.node_id, c.latitude, c.longitude, b.v as way_name FROM way_nodes a, way_tags b, nodes c WHERE a.way_id = b.way_id and a.node_id = c.node_id and b.k = 'name' GROUP BY b.v";
            //Create a list to store the result
            List <WayNodeModel> mainWays = new List <WayNodeModel>();

            //Open connection
            if (this.OpenConnection() == true)
            {
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection);
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    WayNodeModel model = new WayNodeModel();
                    model.setWayId(dataReader["way_id"].ToString());
                    model.setNodeId(dataReader["node_id"].ToString());
                    model.setLatitude(Convert.ToDouble(dataReader["latitude"].ToString()));
                    model.setLongitude(Convert.ToDouble(dataReader["longitude"].ToString()));
                    model.setWayName(dataReader["way_name"].ToString());
                    mainWays.Add(model);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(mainWays);
            }
            else
            {
                return(mainWays);
            }
        }
Esempio n. 2
0
        public WayNodeModel getWayNodeDataAttribute(String name)
        {
            string query = "SELECT a.way_id, a.node_id, c.latitude, c.longitude, b.v as way_name FROM way_nodes a, way_tags b, nodes c WHERE a.way_id = b.way_id and a.node_id = c.node_id and b.k = 'name' and b.v = '" + name + "' group by b.way_id limit 1";
            //Create a list to store the result
            WayNodeModel wayModel = new WayNodeModel();

            //Open connection
            if (this.OpenConnection() == true)
            {
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection);
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    wayModel.setWayId(dataReader["way_id"].ToString());
                    wayModel.setNodeId(dataReader["node_id"].ToString());
                    wayModel.setLatitude(Convert.ToDouble(dataReader["latitude"].ToString()));
                    wayModel.setLongitude(Convert.ToDouble(dataReader["longitude"].ToString()));
                    wayModel.setWayName(dataReader["way_name"].ToString());
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return way to be displayed
                return(wayModel);
            }
            else
            {
                return(wayModel);
            }
        }