Package org.apache.jena.query.spatial

Examples of org.apache.jena.query.spatial.EntityDefinition


  private static final Resource specNoGeoField;

  @Test
  public void EntityHasGeoield() {
    EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler();
    EntityDefinition entityDef = emAssembler.open(null, spec0, null);
    assertEquals(SPEC0_GEO_FIELD, entityDef.getGeoField());
  }
View Full Code Here


  }

  @Test
  public void EntityHasEntityField() {
    EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler();
    EntityDefinition entityDef = emAssembler.open(null, spec0, null);
    assertEquals(SPEC0_ENTITY_FIELD, entityDef.getEntityField());
  }
View Full Code Here

  }

  @Test
  public void EntityHasPair() {
    EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler();
    EntityDefinition entityDef = emAssembler.open(null, spec1, null);
    assertEquals(1, entityDef.getCustomSpatialPredicatePairCount());
    assertEquals(true, entityDef.hasSpatialPredicatePair(
        SPEC1_LATITUDE.asNode(), SPEC1_LONGITUDE.asNode()));

  }
View Full Code Here

  }

  @Test
  public void EntityHasWKT() {
    EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler();
    EntityDefinition entityDef = emAssembler.open(null, spec1, null);
    assertEquals(1, entityDef.getCustomWKTPredicateCount());
    assertEquals(true, entityDef.isWKTPredicate(SPEC1_WKT.asNode()));

  }
View Full Code Here

  }

  @Test
  public void EntityHasMultiplePairsAndWKTs() {
    EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler();
    EntityDefinition entityDef = emAssembler.open(null, spec2, null);
    assertEquals(2, entityDef.getCustomSpatialPredicatePairCount());
    assertEquals(true, entityDef.hasSpatialPredicatePair(
        SPEC2_LATITUDE_1.asNode(), SPEC2_LONGITUDE_1.asNode()));
    assertEquals(true, entityDef.hasSpatialPredicatePair(
        SPEC2_LATITUDE_2.asNode(), SPEC2_LONGITUDE_2.asNode()));
    assertEquals(false, entityDef.hasSpatialPredicatePair(
        SPEC2_LATITUDE_1.asNode(), SPEC2_LONGITUDE_2.asNode()));
    assertEquals(false, entityDef.hasSpatialPredicatePair(
        SPEC2_LATITUDE_2.asNode(), SPEC2_LONGITUDE_1.asNode()));
    assertEquals(2, entityDef.getCustomWKTPredicateCount());
    assertEquals(true, entityDef.isWKTPredicate(SPEC2_WKT_1.asNode()));
    assertEquals(true, entityDef.isWKTPredicate(SPEC2_WKT_2.asNode()));
    assertEquals(false, entityDef.isWKTPredicate(SPEC1_WKT.asNode()));
  }
View Full Code Here

      Log.warn(this,
          "JTS lib is not ready in classpath! An exception should be thrown later on!");
    }

    EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler();
    EntityDefinition entityDef = emAssembler.open(null, spec3, null);
    if (jts_lib_ready) {
      assertEquals("com.spatial4j.core.context.jts.JtsSpatialContext",
          SpatialQuery.ctx.getClass().getName());
    } else {
      assertEquals("com.spatial4j.core.context.SpatialContext",
View Full Code Here

    } else
      throw new SpatialIndexException(
          "URI for the server must begin 'http://'");

    Resource r = GraphUtils.getResourceValue(root, pDefinition);
    EntityDefinition docDef = (EntityDefinition) a.open(r);
    return SpatialDatasetFactory.createSolrIndex(server, docDef);
  }
View Full Code Here

                File dir = new File(path) ;
                directory = FSDirectory.open(dir) ;
            }
       
            Resource r = GraphUtils.getResourceValue(root, pDefinition) ;
            EntityDefinition docDef = (EntityDefinition)a.open(r) ;
           
            return SpatialDatasetFactory.createLuceneIndex(directory, docDef) ;
        } catch (IOException e) { IO.exception(e) ; return null ;}
    }
View Full Code Here

       
        QuerySolution qsol1 = results.get(0) ;
        String entityField = qsol1.getLiteral("entityField").getLexicalForm() ;
        String geoField = qsol1.getLiteral("geoField").getLexicalForm() ;
       
        EntityDefinition docDef = new EntityDefinition(entityField, geoField) ;
       
        String qs2 = StrUtils.strjoinNL("SELECT * { ?definition :hasSpatialPredicatePairs [ list:member [ :latitude ?latitude ; :longitude ?longitude ] ]}") ;
        Query query2 = QueryFactory.create(prologue+" "+qs2) ;
        QueryExecution qexec2 = QueryExecutionFactory.create(query2, model, qsol1) ;
        ResultSet rs2 = qexec2.execSelect() ;
        List<QuerySolution> mapEntries = ResultSetFormatter.toList(rs2) ;
       
        for ( QuerySolution qsol : mapEntries ) {
          Resource latitude = qsol.getResource("latitude") ;
            Resource longitude = qsol.getResource("longitude") ;
            docDef.addSpatialPredicatePair(latitude, longitude);
        }
              
        String qs3 = StrUtils.strjoinNL("SELECT * { ?definition :hasWKTPredicates [ list:member ?wkt ] }") ;
        Query query3 = QueryFactory.create(prologue+" "+qs3) ;
        QueryExecution qexec3 = QueryExecutionFactory.create(query3, model, qsol1) ;
        ResultSet rs3 = qexec3.execSelect() ;
        mapEntries = ResultSetFormatter.toList(rs3) ;
       
        for ( QuerySolution qsol : mapEntries ) {
          Resource wkt = qsol.getResource("wkt") ;
            docDef.addWKTPredicate(wkt);
        }
       
        String qs4 = StrUtils.strjoinNL("SELECT * { ?definition :spatialContextFactory ?factory }") ;
        Query query4 = QueryFactory.create(prologue+" "+qs4) ;
        QueryExecution qexec4 = QueryExecutionFactory.create(query4, model, qsol1) ;
        ResultSet rs4 = qexec4.execSelect() ;
        List<QuerySolution> results4 = ResultSetFormatter.toList(rs4) ;
        if (results4.size() ==0){
          return docDef;
        } else if ( results4.size() !=)  {
            Log.warn(this, "Multiple matches for SpatialContextFactory for : "+root) ;
            throw new SpatialIndexException("Multiple matches for SpatialContextFactory for : "+root) ;
        } else {
          QuerySolution qsol4 = results4.get(0);
          String spatialContextFactory = qsol4.getLiteral("factory").getLexicalForm() ;
          try {
            docDef.setSpatialContextFactory(spatialContextFactory);
          }catch (NoClassDefFoundError e){
            Log.warn(this, "Custom SpatialContextFactory lib is not ready in classpath:"+ e.getMessage()) ;
          }
          return docDef ;
       
View Full Code Here

TOP

Related Classes of org.apache.jena.query.spatial.EntityDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.