Hitachi Vantara Pentaho Community Forums
Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: newMapComponent - dynamic source for shape information?

  1. #21
    Join Date
    Jan 2014
    Posts
    186

    Default

    Great news!
    Now, one question: if you already have access to the GeoJSON feature, why don't you populate the column "shape" with that?
    Imagine that you had the layout:

    Code:
    key     |fill |geoJSON                                                                                             
    --------|-----|--------------------------------------------------------------------------------------------------
    3100104 |100  |{"type":"MultiPolygon","coordinates":[[[[-47.429672447,-18.1654308175596],[-47.429427,-18.1660609975595],[-47.4293999999999,-18.16649793100203 |100  |{"type":"MultiPolygon","coordinates": [[[[-45.1392989999999,-19.2104779965869],[-45.139383,-19.2103539965869],[-45.139648,-19.2099619965
    Then, the addIn wouldn't need to assume that the feature was a multipolygon, and would merely need to do a simple JSON.parse
    I think it would be more general, because it would allow you to have a mixture of polygons, multipolygons, linestrings, etc

  2. #22
    Join Date
    Feb 2017
    Posts
    20

    Default

    Quote Originally Posted by crusso View Post
    Great news!
    Now, one question: if you already have access to the GeoJSON feature, why don't you populate the column "shape" with that?
    Imagine that you had the layout:

    Code:
    key     |fill |geoJSON                                                                                             
    --------|-----|--------------------------------------------------------------------------------------------------
    3100104 |100  |{"type":"MultiPolygon","coordinates":[[[[-47.429672447,-18.1654308175596],[-47.429427,-18.1660609975595],[-47.4293999999999,-18.16649793100203 |100  |{"type":"MultiPolygon","coordinates": [[[[-45.1392989999999,-19.2104779965869],[-45.139383,-19.2103539965869],[-45.139648,-19.2099619965
    Then, the addIn wouldn't need to assume that the feature was a multipolygon, and would merely need to do a simple JSON.parse
    I think it would be more general, because it would allow you to have a mixture of polygons, multipolygons, linestrings, etc
    FANTASTIC!!!! i will try that!!!!

  3. #23
    Join Date
    Feb 2017
    Posts
    20

    Default

    and the new script, works like a charm:
    Code:
    define([
      "cdf/AddIn",
      "cdf/Dashboard.Clean",
      "cdf/lib/jquery",
      "amd!cdf/lib/underscore"
    ], function(AddIn, Dashboard, $, _) {
      
      "use strict";
      
      var inlineGeoJSON = {
        name: "inlineGeoJSON",
        label: "Inline GeoJSON shape resolver",
        defaults: {
          colIdx: null, //column index containing the json map definitions
          idPropertyName: "" //GeoJSON feature property that will be used to index the feature
        },
        implementation: function(tgt, st, opt) {
    
    
          var map = _.chain(st.tableData.resultset)
            .map(function(row, idx){
              return [
                st.ids[idx], polygonToGeoJson(row[opt.colIdx])
              ];
            })
            .object()
            .value();
    
    
          var deferred = $.Deferred();
          deferred.resolve(map);
          return deferred.promise();
        }
      };
    
    
      function polygonToGeoJson(coordinatesStr){
        return {
          type: "Feature",
          geometry: JSON.parse(coordinatesStr)
        };
      }
    
    
      Dashboard.registerGlobalAddIn("NewMapComponent", "ShapeResolver", new AddIn(inlineGeoJSON));
      return inlineGeoJSON;
    });
    with this query result:

    Code:
    key     |fill |geoJSON                                                                                             
    --------|-----|--------------------------------------------------------------------------------------------------
    3100104 |100  |{"type":"MultiPolygon","coordinates":[[[[-47.429672447,-18.1654308175596],[-47.429427,-18.1660609975595],[-47.4293999999999,-18.16649793100203 |100  |{"type":"MultiPolygon","coordinates": [[[[-45.1392989999999,-19.2104779965869],[-45.139383,-19.2103539965869],[-45.139648,-19.2099619965
    Last edited by hugonr; 06-29-2017 at 02:42 PM. Reason: correct code

  4. #24
    Join Date
    Feb 2017
    Posts
    20

    Default

    actually works with 15 records, when i tried like 50 records i got a memory error from chrome....

    i cant figure out how to solve this problem yet.

    cheers!

    update: stops to work with 22 records.

    update 2: tried 300 records in Internet Explorer and works... i need to see what is the problem with chrome
    Last edited by hugonr; 06-29-2017 at 02:53 PM. Reason: update 2

  5. #25
    Join Date
    Jan 2014
    Posts
    186

    Default

    How complex are your polygons?
    In other words, what is the size of the doQuery call that returns the resultset? If it is over a few tens of megabytes, I would expect a slowdown. If it over a few hundred megabytes, yes, it might blow.

    The map component ships with a method for simplifying the geometries, based on the Ramer-Douglas–Peucker algorithm, and is meant to be used when the user is unable to do it server-side.
    It is available from within the addIn as "st._simplifyPoints" . The source code is at https://github.com/webdetails/cde/bl...eConversion.js

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2017 Pentaho Corporation. All Rights Reserved.