private Collection<BaprLocation> GetFromLinkedGeoData(double latitude, double longitude, IUserPreference userPreference)
        {
            string searchHotelsQuery = "SELECT DISTINCT ?lat ?long ?name ?website ?phone ?address ?rooms ?internet_acces"
                + " ?opening_hours ?wheelchair ?stars ?operator"
                + " WHERE { ?s a lgd:Hotel .\n"
                + " ?s rdfs:label ?name . \n"
                + " ?s geo:lat ?lat .\n"
                + " ?s geo:long ?long . \n"
                + "OPTIONAL {?s foaf:homepage ?website .}\n"
                + "OPTIONAL {?s foaf:phone ?phone. }\n"
                + " OPTIONAL {?s lgd:address ?address .}\n "
                + " OPTIONAL {?s lgd:rooms ?rooms.} \n"
                + " OPTIONAL {?s lgd:internet_access ?internet_access.} \n"
                + " OPTIONAL {?s lgd:opening_hours ?opening_hours.} \n"
                + (userPreference.NeedWheelchair ? "?s lgd:wheelchair ?wheelchair. FILTER (?wheelchair =" + BaprAPI.Models.Constants.xsdBooleanIsTrue + ")\n"
                                                      : " OPTIONAL {?s lgd:wheelchair ?wheelchair.} \n")
                + " OPTIONAL {?s lgd:stars ?stars. } \n"
                + " OPTIONAL {?s lgd:operator ?operator. } \n"
                + " FILTER ( ?lat > " + latitude + " - 0.5  && ?lat < " + latitude + " + 0.5"
                + " && ?long > " + longitude + " - 0.5 && ?long < " + longitude + " + 0.5 )\n"
                + "} LIMIT 10";

            SparqlParameterizedString sparqlQueryString = new SparqlParameterizedString();
            sparqlQueryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            sparqlQueryString.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            sparqlQueryString.Namespaces.AddNamespace("lgd", new Uri("http://linkedgeodata.org/ontology/"));
            sparqlQueryString.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            sparqlQueryString.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
            sparqlQueryString.CommandText = searchHotelsQuery;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(sparqlQueryString, @"http://linkedgeodata.org/sparql");
        }
        private Collection<BaprLocation> GetFromDbpedia(double latitude, double longitude, IUserPreference userPreference)
        {
            string searchHotelsQuery = "SELECT DISTINCT ?lat ?long ?name ?website ?address ?number_of_restaurants "
               + "?star_rating ?number_of_rooms ?number_of_suites ?comment ?arhitect ?chain "
                                + " WHERE {\n ?s a dbo:Hotel ."
                                + "?s rdfs:label ?name .\n"
                                + "?s geo:lat ?lat .\n"
                                + "?s geo:long ?long .\n"
                                + "OPTIONAL { ?s rdfs:comment ?comment. FILTER(langMatches(lang(?comment ), \"en\"))}\n"
                                + "OPTIONAL { ?s dbo:arhitect ?arhitect. }\n"
                                + "OPTIONAL { ?s dbp:chain ?chain. }\n"
                                + "OPTIONAL { ?s foaf:homepage ?website .}\n"
                                + "OPTIONAL { ?s dbo:address ?address .}\n"
                                + "OPTIONAL { ?s dbp:numberOfRestaurants ?number_of_restaurants.} \n"
                                + "OPTIONAL { ?s dbp:starRating  ?star_rating. } \n"
                                + "OPTIONAL { ?s dbp:numberOfRooms ?number_of_rooms. } \n"
                                + "OPTIONAL { ?s  dbp:numberOfSuites ?number_of_suites. } \n"
                                + "FILTER ( langMatches(lang(?name), \"EN\")"
                                + " && ?lat > " + latitude + " - 0.5  && ?lat < " + latitude + " + 0.5"
                                + " && ?long > " + longitude + " - 0.5 && ?long < " + longitude + " + 0.5 )\n"
                                + " } LIMIT 10";

            SparqlParameterizedString sparqlQueryString = new SparqlParameterizedString();
            sparqlQueryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            sparqlQueryString.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            sparqlQueryString.Namespaces.AddNamespace("dbo", new Uri("http://dbpedia.org/ontology/"));
            sparqlQueryString.Namespaces.AddNamespace("dbp", new Uri("http://dbpedia.org/property/"));
            sparqlQueryString.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            sparqlQueryString.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
            sparqlQueryString.CommandText = searchHotelsQuery;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(sparqlQueryString, @"http://dbpedia.org/sparql");
        }
        public Collection<BaprLocation> DBpedia_GetRestaurantsNearby(double lat, double lng, IUserPreference userPreference)
        {
            var cuisine = BaprAPI.Utils.Utils.GetCuisines(userPreference, true);
            string queryRestaurantsDBpedia = "SELECT DISTINCT ?name ?lat ?long ?cuisine ?comment ?website ?address ?dress_code ?head_chef ?reservations \n" +
                               " WHERE { \n" +
                                "?f rdf:type dbo:Restaurant .\n" +
                                "?f rdfs:label ?name .\n" +
                                "?f geo:lat ?lat .\n" +
                                "?f geo:long ?long .\n" +
                                "Optional { ?f dbo:cuisine ?cuisine .}\n " +
                                "Optional { ?f rdfs:comment ?comment . FILTER(langMatches(lang(?comment ), \"en\"))}\n " +
                                "Optional { ?f foaf:homepage ?website .}\n " +
                                "Optional { ?f dbo:address ?address .}\n" +
                                "Optional { ?f dbp:dressCode ?dress_code  .} \n" +
                                "Optional { ?f dbp:headChef ?head_chef .} \n" +
                                "Optional { ?f dbp:reservations ?reservations .} \n" +
                                " FILTER ( langMatches(lang(?name), \"EN\")\n" +
                                " && ?lat > " + lat + " - 0.5 && ?lat < " + lat + " + 0.5\n" +
                                " && ?long > " + lng + " - 0.5 && ?long < " + lng + " + 0.5\n" +
                                (!string.IsNullOrEmpty(cuisine) ? " && lcase(?cuisine) in (" + cuisine + ") " : string.Empty) +
                                ")}\n" +"LIMIT 30";

            //Create a Parameterized String
            SparqlParameterizedString queryString = new SparqlParameterizedString();
            //Add a namespace declaration
            queryString.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            queryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            queryString.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            queryString.Namespaces.AddNamespace("dbo", new Uri("http://dbpedia.org/ontology/"));
            queryString.Namespaces.AddNamespace("dbp", new Uri("http://dbpedia.org/property/"));
            queryString.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
            queryString.CommandText = queryRestaurantsDBpedia;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(queryString, @"http://dbpedia.org/sparql");
        }
Exemplo n.º 4
0
 public void Init()
 {
     _fakeView           = Substitute.For <ISettingsView>();
     _fakeModel          = Substitute.For <ISettingsModel>();
     _fakeUserPreference = Substitute.For <IUserPreference>();
     _uut = new SettingsPresenter(_fakeView, _fakeModel, _fakeUserPreference);
 }
        private Collection<BaprLocation> DbPedia_GetMuseumsNearby(double lat, double lng, IUserPreference userPreference)
        {
            string myQuery = "SELECT DISTINCT ?name ?website ?address ?phone ?lat ?long ?museum_type ?publictransit ?comment \n" +
                           "WHERE {	\n" +
                           "?museum a ?type. \n" +
                           "?museum ?p ?name. \n" +
                           "Optional { ?museum dbpproperty:address ?address. }" +
                           "Optional { ?museum dbpproperty:website ?website. }\n" +
                           "Optional { ?museum foaf:phone ?phone. }" +
                           "Optional { ?museum dbpproperty:type ?museum_type. }" +
                           "Optional { ?museum dbpproperty:publictransit ?publictransit. }" +
                           "Optional { ?s rdfs:comment ?comment. FILTER(langMatches(lang(?comment ), \"en\"))}\n" +
                           "?museum geo:lat ?lat.\n" +
                           "?museum geo:long ?long.\n" +
                           "FILTER (?p=<http://www.w3.org/2000/01/rdf-schema#label>).\n" +
                           "FILTER (?type IN (<http://dbpedia.org/ontology/Museum>, <http://schema.org/Museum>, <http://dbpedia.org/class/yago/Museum103800563>)).\n" +
                           "FILTER ( ?long > " + lng + " - 0.5 && ?long < " + lng + " + 0.5 && \n" +
                           "?lat > " + lat + " - 0.5 && ?lat < " + lat + " + 0.5)\n" +
                           "FILTER ( lang(?name) = 'en')}\n" +
                           "LIMIT 30";

            SparqlParameterizedString dbpediaQuery = new SparqlParameterizedString();

            dbpediaQuery.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            dbpediaQuery.Namespaces.AddNamespace("dbpedia-owl", new Uri("http://dbpedia.org/ontology/"));
            dbpediaQuery.Namespaces.AddNamespace("dbpproperty", new Uri("http://dbpedia.org/property/"));
            dbpediaQuery.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/spec/"));
            dbpediaQuery.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            dbpediaQuery.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            dbpediaQuery.CommandText = myQuery;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(dbpediaQuery, @"http://dbpedia.org/sparql");
        }
        private Collection<BaprLocation> LinkedGeoData_GetMuseumsNearby(double lat, double lng, IUserPreference userPreference)
        {
            string myQuery = "SELECT DISTINCT ?name ?address ?homepage ?lat ?long  ?opening_hours \n" +
                            "WHERE {	\n" +
                            "?museum a ?type. \n" +
                            "?museum ?p ?name. \n" +
                            "Optional { ?museum lgdo:address ?address. }\n" +
                            "Optional { ?museum foaf:homepage ?homepage. }\n" +
                            "Optional { ?museum foaf:phone ?phone. }\n" +
                            "Optional { ?museum lgdo:opening_hours ?opening_hours .}\n " +
                            "?museum geo:lat ?lat.\n" +
                            "?museum geo:long ?long.\n" +
                            "FILTER (?p=<http://www.w3.org/2000/01/rdf-schema#label>).\n" +
                            "FILTER (?type IN (<http://linkedgeodata.org/ontology/Museum>, <http://schema.org/Museum>)).\n" +
                            "FILTER ( ?long > " + lng + " - 0.5 && ?long < " + lng + " + 0.5 && \n" +
                            "?lat > " + lat + " - 0.5 && ?lat < " + lat + " + 0.5)}\n" +
                            "LIMIT 30";

            SparqlParameterizedString dbpediaQuery = new SparqlParameterizedString();

            dbpediaQuery.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            dbpediaQuery.Namespaces.AddNamespace("lgdo", new Uri("http://linkedgeodata.org/ontology/"));
            dbpediaQuery.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/spec/"));
            dbpediaQuery.CommandText = myQuery;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(dbpediaQuery, @"http://linkedgeodata.org/sparql");
        }
Exemplo n.º 7
0
        public Collection<BaprLocation> DbPedia_GetShopsNearby(double lat, double lng, IUserPreference userPreference)
        {
            string myQuery = "SELECT DISTINCT ?name ?address ?opening_hours ?number_of_stores ?floors ?parking ?lat ?long  \n" +
                           "WHERE {	\n" +
                           "?shop a ?type. \n" +
                           "?shop ?p ?name. \n" +
                           "Optional { ?shop dbpproperty:address ?address. }" +
                           "Optional { ?shop schema:openingHours ?opening_hours. }\n" +
                           "Optional { ?shop dbpproperty:floors ?floors. }\n" +
                           "Optional { ?shop dbpproperty:numberOfStores ?number_of_stores. }\n" +
                           "Optional { ?shop dbpproperty:parking ?parking. }\n" +
                           "?shop geo:lat ?lat.\n" +
                           "?shop geo:long ?long.\n" +
                           "FILTER (?p=<http://www.w3.org/2000/01/rdf-schema#label>).\n" +
                           "FILTER (?type IN (<http://dbpedia.org/ontology/ShoppingMall>, <http://schema.org/ShoppingCenter>)).\n" +
                           "FILTER ( ?long > " + lng + " - 0.5 && ?long < " + lng + " + 0.5 && \n" +
                           "?lat > " + lat + " - 0.5 && ?lat < " + lat + " + 0.5)\n" +
                           "FILTER ( lang(?name) = 'en')}\n" +
                           "LIMIT 30";

            SparqlParameterizedString dbpediaQuery = new SparqlParameterizedString();

            dbpediaQuery.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            dbpediaQuery.Namespaces.AddNamespace("dbpproperty", new Uri("http://dbpedia.org/property/"));
            dbpediaQuery.Namespaces.AddNamespace("schema", new Uri("http://schema.org/"));
            dbpediaQuery.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            dbpediaQuery.CommandText = myQuery;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(dbpediaQuery, @"http://dbpedia.org/sparql");
        }
        public ICollection<BaprLocation> GetFromLinkedGeoData(string text, double latitude, double longitude, IUserPreference userPreference)
        {
            var cuisine = BaprAPI.Utils.Utils.GetCuisines(userPreference, false);
            string searchQueryByText = "SELECT DISTINCT ?lat ?long ?name ?website ?cuisine ?address ?opening_hours ?wheelchair WHERE {\n"
                + "?s geo:lat ?lat .\n"
                + "?s geo:long ?long .\n"
                + "?s rdfs:label ?name. \n"
                + "?s a ?type. \n"
                + "OPTIONAL { ?s foaf:homepage ?website .}\n"
                + "OPTIONAL { ?s lgd:cuisine ?cuisine .}\n"
                + "OPTIONAL { ?s lgd:address ?address .}\n "
                + "OPTIONAL { ?s lgd:opening_hours  ?opening_hours .}\n "
                + (userPreference.NeedWheelchair ? "?s lgd:wheelchair ?wheelchair. FILTER (?wheelchair =" + BaprAPI.Models.Constants.xsdBooleanIsTrue + ")\n"
                                                      : " OPTIONAL {?s lgd:wheelchair ?wheelchair.} \n")
                + "FILTER (langMatches(lang(?name ), \"en\") \n"
                + " && ?lat > " + latitude + " - 0.5 && ?lat < " + latitude + " + 0.5 "
                + " && ?long > " + longitude + " - 0.5 && ?long < " + longitude + " + 0.5\n"
                + " && contains(lcase(?name),lcase(\"" + text.ToLower() + "\"))\n"
                + " && ((?type = lgd:Restaurant " + (!string.IsNullOrEmpty(cuisine) ? "&& lcase(?cuisine) in (" + cuisine + ")" : string.Empty) + ") \n"
                        + "|| ?type = lgd:Hospital || ?type = lgd:Bar || ?type = lgd:Bank \n"
                        + "|| ?type = lgd:Pharmacy || ?type = lgd:FastFood || ?type=lgd:Cafe || ?type=lgd:Pub || ?type= lgd:Theatre"
                        + "|| ?type = lgd:Museum))"
                + "} LIMIT 10";

            SparqlParameterizedString sparqlQueryString = new SparqlParameterizedString();
            sparqlQueryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            sparqlQueryString.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            sparqlQueryString.Namespaces.AddNamespace("lgd", new Uri("http://linkedgeodata.org/ontology/"));
            sparqlQueryString.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            sparqlQueryString.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
            sparqlQueryString.CommandText = searchQueryByText;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(sparqlQueryString, @"http://linkedgeodata.org/sparql");
        }
        private Collection<BaprLocation> DbPedia_GetAllHospitalsNearby(double lat, double lng, IUserPreference userPreference)
        {
            string myQuery = "SELECT DISTINCT ?name ?website ?address ?phone ?lat ?long ?department ?opening_year ?health_care ?bed_count\n" +
                            "WHERE {	\n" +
                            "?hospital a ?type. \n" +
                            "?hospital ?p ?name. \n" +
                            "Optional { ?hospital dbo:address ?address .}\n" +
                            "Optional { ?hospital dbpproperty:website ?website. }\n" +
                            "Optional { ?hospital foaf:phone ?phone. }\n" +
                            "Optional { ?hospital schema:department ?department} \n" +
                            "Optional { ?hospital dbo:openingYear ?opening_year} \n" +
                             "Optional { ?hospital dbpproperty:healthcare ?health_care} \n" +
                              "Optional { ?hospital dbo:bedCount ?bed_count} \n" +
                            "?hospital geo:lat ?lat.\n" +
                            "?hospital geo:long ?long.\n" +
                            "FILTER (?p=<http://www.w3.org/2000/01/rdf-schema#label>).\n" +
                            "FILTER (?type IN (<http://dbpedia.org/ontology/Hospital>, <http://schema.org/Hospital>)).\n" +
                            "FILTER ( ?long > " + lng + " - 0.5 && ?long < " + lng + " + 0.5 && \n" +
                            "?lat > " + lat + " - 0.5 && ?lat < " + lat + " + 0.5)\n" +
                            "FILTER ( lang(?name) = 'en')}\n" +
                            "LIMIT 30";

            SparqlParameterizedString dbpediaQuery = new SparqlParameterizedString();

            dbpediaQuery.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            dbpediaQuery.Namespaces.AddNamespace("dbpproperty", new Uri("http://dbpedia.org/property/"));
            dbpediaQuery.Namespaces.AddNamespace("dbo", new Uri("http://dbpedia.org/ontology/"));
            dbpediaQuery.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/spec/"));
            dbpediaQuery.Namespaces.AddNamespace("schema", new Uri("http://schema.org/"));
            dbpediaQuery.CommandText = myQuery;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(dbpediaQuery, @"http://dbpedia.org/sparql");
        }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            AddTab("Mine sager", new MyCasesFragment());
            AddTab("Seneste sager", new AllCasesFragment());

            _userPreference = ModelFactory.Instance.CreateUserPreference();
            _userPreference.SetUserPreference();
            SetUserPreferences();
        }
Exemplo n.º 11
0
 private ModelFactory()
 {
     _tcApi               = new TCApi();
     _logInModel          = new LogInModel(_tcApi);
     _homeModel           = new HomeModel(_tcApi);
     _userPreference      = new UserPreference(_tcApi);
     _settingsModel       = new SettingsModel();
     _createUserModel     = new CreateUserModel(_tcApi);
     _createCaseModel     = new CreateCaseModel(_tcApi);
     _caseModel           = new CaseModel(_tcApi);
     _changePasswordModel = new ChangePasswordModel(_tcApi);
     _mapModel            = new MapModel(_tcApi);
     _trafficLightModel   = new TrafficLightOverviewModel(_tcApi);
 }
        public Collection<BaprLocation> Linkedgeodata_GetRestaurantsNearby(double lat, double lng, IUserPreference userPreference)
        {
            var cuisine = BaprAPI.Utils.Utils.GetCuisines(userPreference, false);
            string queryRestaurantsLinkedgeodata = "SELECT DISTINCT ?name ?lat ?long ?cuisine ?comment ?wheelchair ?website ?address ?smoking ?internet_access ?wifi ?fast_food \n" +
                               " WHERE { \n" +
                                "?f rdf:type lgdo:Restaurant .\n" +
                                "?f rdfs:label ?name .\n" +
                                "?f geo:lat ?lat .\n" +
                                "?f geo:long ?long .\n" +
                                "Optional { ?f lgdo:cuisine ?cuisine .}\n " +
                                "Optional { ?f rdfs:comment ?comment . FILTER(langMatches(lang(?comment ), \"en\"))}\n " +
                                "Optional { ?f foaf:homepage ?website .}\n " +
                                "Optional { ?f lgdo:address ?address .}\n " +
                                "Optional { ?f lgdo:opening_hours ?opening_hours .}\n " +
                                "Optional { ?f lgdo:smoking  ?smoking .} \n" +
                                "Optional { ?f lgdo:internet_access ?internet_access .}\n" +
                                "Optional { ?f lgdo:wifi  ?wifi .}\n " +
                                "Optional { ?f lgdo:fast_food  ?fast_food .} \n" +
                                (userPreference.NeedWheelchair ? "?f lgdo:wheelchair ?wheelchair. FILTER (?wheelchair =" + BaprAPI.Models.Constants.xsdBooleanIsTrue + ")\n"
                                                      : " OPTIONAL {?f lgdo:wheelchair ?wheelchair.} \n")+
                                " FILTER ( langMatches(lang(?name), \"EN\")\n" +
                                " && ?lat > " + lat + " - 0.5 && ?lat < " + lat + " + 0.5\n" +
                                " && ?long > " + lng + " - 0.5 && ?long < " + lng + " + 0.5" +
                                (!string.IsNullOrEmpty(cuisine) ? "&& lcase(?cuisine) in (" + cuisine + ") \n" : string.Empty) +
                                 ")}\n" +
                                "LIMIT 30";

            //Create a Parameterized String
            SparqlParameterizedString queryString = new SparqlParameterizedString();
            //Add a namespace declaration
            queryString.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            queryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            queryString.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            queryString.Namespaces.AddNamespace("lgdo", new Uri("http://linkedgeodata.org/ontology/"));
            queryString.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
            queryString.CommandText = queryRestaurantsLinkedgeodata;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(queryString, @"http://linkedgeodata.org/sparql");
        }
        public ICollection<BaprLocation> GetFromDbpedia(string text, double latitude, double longitude, IUserPreference userPreference)
        {
            var cuisineFromDb = BaprAPI.Utils.Utils.GetCuisines(userPreference, true);
            var interests = BaprAPI.Utils.Utils.GetInterests(userPreference);
            string searchQueryByText = "SELECT DISTINCT ?lat ?long ?name ?address ?cuisine ?website ?established ?comment WHERE{\n"
              + "?s a dbo:Location .\n"
              + "?s geo:lat ?lat .\n"
              + "?s geo:long ?long .\n"
              + "?s rdfs:label ?name.\n"
              + "?s a ?type. \n"
              + "OPTIONAL { ?s dbp:established ?established.}\n"
              + "OPTIONAL { ?s rdfs:comment ?comment. FILTER(langMatches(lang(?comment ), \"en\"))}\n"
              + "OPTIONAL { ?s dbo:address ?address .}\n "
              + "OPTIONAL { ?s dbo:cuisine ?cuisine .}\n"
              + "OPTIONAL { ?s foaf:homepage ?website .}\n"
              + "FILTER(langMatches(lang(?name ), \"en\") "
                + " && ?lat >" + latitude + " - 0.5 && ?lat < " + latitude + "+ 0.5 "
                + " && ?long > " + longitude + " - 0.5 && ?long < " + longitude + " + 0.5"
               + "  && contains(lcase(?name),lcase(\"" + text.ToLower() + "\"))"
               + "  && ((?type=dbo:Restaurant " + (!string.IsNullOrEmpty(cuisineFromDb) ? "&& lcase(?cuisine) in (" + cuisineFromDb + ")" : string.Empty) + ")\n"
                      + "|| (?type = dbo:Museum  " + (!string.IsNullOrEmpty(interests) ? " &&?type in (" + interests + ")" : string.Empty) + ")\n"

                      + "|| ?type=dbo:Town || ?type=dbo:Village "
                      + "|| ?type=dbo:Park || ?type=dbo:Garden || ?type=dbo:HistoricPlace || ?type=dbo:Monument)) "
              + "}LIMIT 10";

            SparqlParameterizedString sparqlQueryString = new SparqlParameterizedString();
            sparqlQueryString.Namespaces.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            sparqlQueryString.Namespaces.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            sparqlQueryString.Namespaces.AddNamespace("dbo", new Uri("http://dbpedia.org/ontology/"));
            sparqlQueryString.Namespaces.AddNamespace("geo", new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#"));
            sparqlQueryString.Namespaces.AddNamespace("dbp", new Uri("http://dbpedia.org/property/"));
            sparqlQueryString.Namespaces.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
            sparqlQueryString.CommandText = searchQueryByText;

            return BaprAPI.Utils.Utils.ParseSparqlQuery(sparqlQueryString, @"http://dbpedia.org/sparql");
        }
Exemplo n.º 14
0
 public SettingsPresenter(ISettingsView settingsView, ISettingsModel settingsModel, IUserPreference userPreference)
 {
     _settingsView   = settingsView;
     _settingsModel  = settingsModel;
     _userPreference = userPreference;
 }
Exemplo n.º 15
0
 public static string GetCuisines(IUserPreference userPreference, bool addXsdSTring)
 {
     var result = string.Empty;
     if (userPreference != null && userPreference.Cuisine != null)
     {
         var cuisines = userPreference.Cuisine.Where(c => c.Checked == true).Select(c => c.Name.ToLower());
         foreach (var cuisine in cuisines)
         {
             result = result + "\"" + cuisine + "\"" + (addXsdSTring ? Constants.xsdString : string.Empty) + ",";
         }
         result = !string.IsNullOrEmpty(result) ? result.Remove(result.Length - 1) : result;
     }
     return result;
 }
Exemplo n.º 16
0
        public static string GetInterests(IUserPreference userPreference)
        {
            var result = string.Empty;
            if (userPreference != null && userPreference.Interests != null)
            {
                var interests = userPreference.Interests.Where(c => c.Checked == true).Select(c => c.Name.ToLower());
                foreach (var interest in interests)
                {
                    result = result + string.Format("<http://dbpedia.org/resource/{0}>", interest) + ",";
                }
                result = !string.IsNullOrEmpty(result) ? result.Remove(result.Length - 1) : result;

            }

            return result;
        }
Exemplo n.º 17
0
        public static void SetValue <T>(this IUserPreference pref, PrefKeys key, T value)
        {
            string strKey = key.ToString();

            pref.SetValue(strKey, value);
        }
Exemplo n.º 18
0
        public static T GetValue <T>(this IUserPreference pref, PrefKeys key)
        {
            string strKey = key.ToString();

            return(pref.GetValue <T>(strKey, (T)DefaultValues[key]));
        }