@Override public Geometry getGeometry(String articleName, Language language, String layerName, String refSysName) throws DaoException { LocalPage lp = localPageDao.getByTitle(new Title(articleName, language), NameSpace.ARTICLE); if (lp == null) return null; Integer id = wikidataDao.getItemId(lp); if (id == null) throw new DaoException("Could not find Wikidata item for \"" + lp.toString() + "\""); return getGeometry(id, layerName); }
@Override public Geometry getGeometry(String articleName, Language language, String layerName, String refSysName) throws DaoException { LocalPage lp = localPageDao.getByTitle(new Title(articleName, language), NameSpace.ARTICLE); if (lp == null) return null; Integer id = wikidataDao.getItemId(lp); if (id == null) throw new DaoException("Could not find Wikidata item for \"" + lp.toString() + "\""); return getGeometry(id, layerName); }
Integer id = wdDao.getItemId(lp); Geometry rootPoint = sdDao.getGeometry(id, layerName, "earth"); Map<Integer, Geometry> resMap = snDao.getNeighbors(rootPoint, layerName, "earth", new HashSet<Integer>());
Integer id = wdDao.getItemId(lp); Geometry rootPoint = sdDao.getGeometry(id, layerName, "earth"); Map<Integer, Geometry> resMap = snDao.getNeighbors(rootPoint, layerName, "earth", new HashSet<Integer>());
Integer containerId1 = wdDao.getItemId(lpDao.getByTitle(new Title("China", Language.getByLangCode("simple")), NameSpace.ARTICLE)); TIntSet containedItemIds1 = scDao.getContainedItemIds(containerId1,layerName1, "earth", subLayers, SpatialContainmentDao.ContainmentOperationType.CONTAINMENT); Integer containerId2 = wdDao.getItemId(lpDao.getByTitle(new Title("California", Language.getByLangCode("simple")), NameSpace.ARTICLE)); TIntSet containedItemIds2 = scDao.getContainedItemIds(containerId2,layerName2, "earth", subLayers, SpatialContainmentDao.ContainmentOperationType.CONTAINMENT);
Integer containerId1 = wdDao.getItemId(lpDao.getByTitle(new Title("China", Language.getByLangCode("simple")), NameSpace.ARTICLE)); TIntSet containedItemIds1 = scDao.getContainedItemIds(containerId1,layerName1, "earth", subLayers, SpatialContainmentDao.ContainmentOperationType.CONTAINMENT); Integer containerId2 = wdDao.getItemId(lpDao.getByTitle(new Title("California", Language.getByLangCode("simple")), NameSpace.ARTICLE)); TIntSet containedItemIds2 = scDao.getContainedItemIds(containerId2,layerName2, "earth", subLayers, SpatialContainmentDao.ContainmentOperationType.CONTAINMENT);
public static void main(String[] args){ try { Env env = new EnvBuilder().build(); Configurator c = env.getConfigurator(); SpatialContainmentDao scDao = c.get(SpatialContainmentDao.class); WikidataDao wdDao = c.get(WikidataDao.class); LocalPageDao lpDao = c.get(LocalPageDao.class); LanguageSet loadedLangs = lpDao.getLoadedLanguages(); // set up the parameters for the call to getContainedItemIds String containerName = "Israel"; Set<String> subLayers = Sets.newHashSet(); subLayers.add("wikidata"); LocalPage lp = lpDao.getByTitle(new Title(containerName,Language.getByLangCode("simple")), NameSpace.ARTICLE); Integer id = wdDao.getItemId(lp); TIntSet containedItemIds = scDao.getContainedItemIds(id, Layers.COUNTRY, RefSys.EARTH, subLayers, SpatialContainmentDao.ContainmentOperationType.CONTAINMENT); int counter = 0; System.out.println("Items contained in the spatial footprint of the article '" + lp.getTitle() + "' are:"); for (int cId : containedItemIds.toArray()){ UniversalPage univPage = wdDao.getUniversalPage(cId); Title t = univPage.getBestEnglishTitle(lpDao, true); System.out.println(t.getCanonicalTitle()); counter++; } System.out.printf("Found %d items\n", counter); } catch(Exception e){ e.printStackTrace(); } }
Integer itemId = wdDao.getItemId(localPage);
public static void main(String[] args){ try { Env env = new EnvBuilder().build(); Configurator c = env.getConfigurator(); SpatialContainmentDao scDao = c.get(SpatialContainmentDao.class); WikidataDao wdDao = c.get(WikidataDao.class); LocalPageDao lpDao = c.get(LocalPageDao.class); LanguageSet loadedLangs = lpDao.getLoadedLanguages(); // set up the parameters for the call to getContainedItemIds String containerName = "Israel"; Set<String> subLayers = Sets.newHashSet(); subLayers.add("wikidata"); LocalPage lp = lpDao.getByTitle(new Title(containerName,Language.getByLangCode("simple")), NameSpace.ARTICLE); Integer id = wdDao.getItemId(lp); TIntSet containedItemIds = scDao.getContainedItemIds(id, Layers.COUNTRY, RefSys.EARTH, subLayers, SpatialContainmentDao.ContainmentOperationType.CONTAINMENT); int counter = 0; System.out.println("Items contained in the spatial footprint of the article '" + lp.getTitle() + "' are:"); for (int cId : containedItemIds.toArray()){ UniversalPage univPage = wdDao.getUniversalPage(cId); Title t = univPage.getBestEnglishTitle(lpDao, true); System.out.println(t.getCanonicalTitle()); counter++; } System.out.printf("Found %d items\n", counter); } catch(Exception e){ e.printStackTrace(); } }
Integer itemId = wdDao.getItemId(localPage);
Integer id = wdDao.getItemId(lp); Geometry rootPoint = sdDao.getGeometry(id, layerName, "earth"); Map<Integer, Geometry> resMap = snDao.getKNNeighbors(id, 100, layerName, "earth" , new HashSet<Integer>());
Integer id = wdDao.getItemId(lp); Geometry rootPoint = sdDao.getGeometry(id, layerName, "earth"); Map<Integer, Geometry> resMap = snDao.getKNNeighbors(id, 100, layerName, "earth" , new HashSet<Integer>());
public static void main(String[] args) throws ConfigurationException, DaoException{ DistanceMetrics distanceMetrics = new DistanceMetrics(); Env env = new EnvBuilder().build(); Configurator c = env.getConfigurator(); SpatialNeighborDao snDao = c.get(SpatialNeighborDao.class); WikidataDao wdDao = c.get(WikidataDao.class); LocalPageDao lpDao = c.get(LocalPageDao.class); SpatialDataDao sdDao = c.get(SpatialDataDao.class); LanguageSet loadedLangs = lpDao.getLoadedLanguages(); // set up the parameters for the call to getContainedItemIds String originName = "University of Minnesota"; String endName = "Wisconsin"; String layerName = "wikidata"; LocalPage originLP = lpDao.getByTitle(new Title(originName, Language.getByLangCode("simple")), NameSpace.ARTICLE); LocalPage endLP = lpDao.getByTitle(new Title(endName, Language.getByLangCode("simple")), NameSpace.ARTICLE); Integer originId = wdDao.getItemId(originLP); Integer endId = wdDao.getItemId(endLP); Geometry originPoint = sdDao.getGeometry(originId, layerName, "earth"); Geometry endPoint = sdDao.getGeometry(endId, layerName, "earth"); System.out.println("Straight-line distance " + distanceMetrics.getDistance(originPoint, endPoint)); System.out.println("KNN Distance " + distanceMetrics.getTopologicalDistance(originPoint, originId, endPoint, endId, 1, layerName, "earth")); }
public static void main(String[] args) throws ConfigurationException, DaoException{ DistanceMetrics distanceMetrics = new DistanceMetrics(); Env env = new EnvBuilder().build(); Configurator c = env.getConfigurator(); SpatialNeighborDao snDao = c.get(SpatialNeighborDao.class); WikidataDao wdDao = c.get(WikidataDao.class); LocalPageDao lpDao = c.get(LocalPageDao.class); SpatialDataDao sdDao = c.get(SpatialDataDao.class); LanguageSet loadedLangs = lpDao.getLoadedLanguages(); // set up the parameters for the call to getContainedItemIds String originName = "University of Minnesota"; String endName = "Wisconsin"; String layerName = "wikidata"; LocalPage originLP = lpDao.getByTitle(new Title(originName, Language.getByLangCode("simple")), NameSpace.ARTICLE); LocalPage endLP = lpDao.getByTitle(new Title(endName, Language.getByLangCode("simple")), NameSpace.ARTICLE); Integer originId = wdDao.getItemId(originLP); Integer endId = wdDao.getItemId(endLP); Geometry originPoint = sdDao.getGeometry(originId, layerName, "earth"); Geometry endPoint = sdDao.getGeometry(endId, layerName, "earth"); System.out.println("Straight-line distance " + distanceMetrics.getDistance(originPoint, endPoint)); System.out.println("KNN Distance " + distanceMetrics.getTopologicalDistance(originPoint, originId, endPoint, endId, 1, layerName, "earth")); }