Code Monkey home page Code Monkey logo

matlab-gmlread's People

Contributors

jstockwin avatar

Watchers

 avatar  avatar

matlab-gmlread's Issues

Error/argument handling

We should really be checking inputs etc etc

e.g.

% Validate input args
narginchk(1,Inf);

% Get Filename
if ~ischar(filename) && ~(isstring(filename) && isscalar(filename))
    error(message('MATLAB:csvread:FileNameMustBeString')); 
end
filename = char(filename);

% Make sure file exists
if exist(filename,'file') ~= 2 
    error(message('MATLAB:csvread:FileNotFound'));
end

Nested properties will break the function

It is possible that we have the following:

node
[
    id 1
    graphics
    [
        x 1
        y 1
    ]
   label "test"
]

This sort of nested structure is not supported.

  • It will try to add a graphics column to the NodeProps, but finding the value for graphics may error, or it may just be blank
  • The [ after graphics will be ignored
  • The x and y will be added to NodeProps, although with no information about being nested under graphics.
  • The ] of graphics will set interpreting_node = 0; which will lead to label either being ignored, or throwing some kind of errors.

We probably need some concept of depth.

Duplicated code

Currently, the code is very linear and explicit. There are a few lines that are duplicated, specifically between handling edges and handling nodes.

It might be worth having some additional util functions, or maybe combining the edge/node logic into one.

More generic handling of NodeProps

cc:/ @Tom-Johnston

We could handle any given property e.g. using regexp(tline, '(?<=^\s*)([^ \t]+)', 'match').

For a tline of

                    some_property some_value

that regexp code will result in 'some_property'. We'll then be able to create a list of all properties present in the gml file on the first run through, then initialise the NodeProps table with these columns.

If we're lucky, on the second run through we might be able to do something like

prop = regexp(tline, '(?<=^\s*)([^ \t]+)', 'match');
NodeProps.eval(prop){current_node} = some_other_reg_exp_to_get_some_value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.