Package org.apache.jena.query.spatial

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


    }

    List<Node> list = argObject.getArgList();

    if (list.size() < 4 || list.size() > 5)
      throw new SpatialIndexException("Change in object list size");

    int idx = 0;

    Node x = list.get(idx);
    if (!x.isLiteral()) {
View Full Code Here


    }

    List<Node> list = argObject.getArgList();

    if (list.size() < 2 || list.size() > 3)
      throw new SpatialIndexException("Change in object list size");

    int idx = 0;

    Node x = list.get(idx);
    if (!x.isLiteral()) {
View Full Code Here

  @Override
  public SpatialIndex open(Assembler a, Resource root, Mode mode) {
    String uri = GraphUtils.getResourceValue(root, pServer).getURI();
    SolrServer server;
    if (uri.startsWith("embedded:")) {
        throw new SpatialIndexException("Embedded Solr server not supported (change code and dependencies to enable)") ;
//      try {
//              if ( ! GraphUtils.exactlyOneProperty(root, pSolrHome) )
//                  throw new SpatialIndexException("No 'spatial:solrHome' property on EmbeddedSolrServer "+root) ;
//             
//              RDFNode n = root.getProperty(pSolrHome).getObject() ;
//             
//              if (n.isLiteral()){
//                throw new SpatialIndexException ("No 'spatial:solrHome' property on EmbeddedSolrServer "+root+ " is a literal and not a Resource/URI");
//              }
//                Resource x = n.asResource() ;
//                String path = IRILib.IRIToFilename(x.getURI()) ;
//       
//        System.setProperty("solr.solr.home", path);
//        String coreName = uri.substring("embedded:".length());
//        CoreContainer.Initializer initializer = new CoreContainer.Initializer();
//        CoreContainer coreContainer = initializer.initialize();
//        server = new EmbeddedSolrServer(coreContainer, coreName);
//      } catch (FileNotFoundException e) {
//        throw new SpatialIndexException(e);
//        // throw new
//        // SpatialIndexException("Embedded Solr server not supported (change code and dependencies to enable)")
//        // ;
//      }
    } else if (uri.startsWith("http://")) {
      server = new HttpSolrServer(uri);
    } 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

    public SpatialIndex open(Assembler a, Resource root, Mode mode)
    {
        try
        {
            if ( ! GraphUtils.exactlyOneProperty(root, pDirectory) )
                throw new SpatialIndexException("No 'spatial:directory' property on "+root) ;
           
            Directory directory ;
            RDFNode n = root.getProperty(pDirectory).getObject() ;
            if ( n.isLiteral() )
            {
                if ( ! "mem".equals(n.asLiteral().getLexicalForm()) )
                    throw new SpatialIndexException("No 'spatial:directory' property on "+root+ " is a literal and not \"mem\"") ;
                 directory = new RAMDirectory() ;
            }
            else
            {
                Resource x = n.asResource() ;
View Full Code Here

        QueryExecution qexec1 = QueryExecutionFactory.create(query1, model) ;
        ResultSet rs1 = qexec1.execSelect() ;
        List<QuerySolution> results = ResultSetFormatter.toList(rs1) ;
        if ( results.size() == 0 ) {
            //Log.warn(this, "Failed to find a valid EntityDefinition for : "+root) ;
            throw new SpatialIndexException("Failed to find a valid EntityDefinition for : "+root) ;
        }
       
        if ( results.size() !=1 )  {
            Log.warn(this, "Multiple matches for EntityMap for : "+root) ;
            throw new SpatialIndexException("Multiple matches for EntityDefinition for : "+root) ;
        }
       
        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);
View Full Code Here

    }

    List<Node> list = argObject.getArgList();

    if (list.size() < 3 || list.size() > 5)
      throw new SpatialIndexException("Change in object list size");

    int idx = 0;

    Node x = list.get(idx);
    if (!x.isLiteral()) {
View Full Code Here

                    System.out.println("  "+f.name()+" = "+f.stringValue()) ;
                }
               
            }

        } catch (Exception ex) { throw new SpatialIndexException(ex) ; }
       
    }
View Full Code Here

    }

    List<Node> list = argObject.getArgList();

    if (list.size() < 3 || list.size() > 5)
      throw new SpatialIndexException("Change in object list size");

    int idx = 0;

    Node x = list.get(idx);
    if (!x.isLiteral()) {
View Full Code Here

TOP

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

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.